@@ -816,7 +816,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
816816 }
817817 // For legacy and API support only full commit sha
818818 parts := strings .Split (path , "/" )
819- if len (parts ) > 0 && len (parts [0 ]) == 40 {
819+ if len (parts ) > 0 && len (parts [0 ]) == git . SHAFullLength {
820820 ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
821821 return parts [0 ]
822822 }
@@ -852,7 +852,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
852852 return getRefNameFromPath (ctx , path , ctx .Repo .GitRepo .IsTagExist )
853853 case RepoRefCommit :
854854 parts := strings .Split (path , "/" )
855- if len (parts ) > 0 && len (parts [0 ]) >= 7 && len (parts [0 ]) <= 40 {
855+ if len (parts ) > 0 && len (parts [0 ]) >= 7 && len (parts [0 ]) <= git . SHAFullLength {
856856 ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
857857 return parts [0 ]
858858 }
@@ -961,7 +961,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
961961 return
962962 }
963963 ctx .Repo .CommitID = ctx .Repo .Commit .ID .String ()
964- } else if len (refName ) >= 7 && len (refName ) <= 40 {
964+ } else if len (refName ) >= 7 && len (refName ) <= git . SHAFullLength {
965965 ctx .Repo .IsViewCommit = true
966966 ctx .Repo .CommitID = refName
967967
@@ -971,7 +971,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
971971 return
972972 }
973973 // If short commit ID add canonical link header
974- if len (refName ) < 40 {
974+ if len (refName ) < git . SHAFullLength {
975975 ctx .RespHeader ().Set ("Link" , fmt .Sprintf ("<%s>; rel=\" canonical\" " ,
976976 util .URLJoin (setting .AppURL , strings .Replace (ctx .Req .URL .RequestURI (), util .PathEscapeSegments (refName ), url .PathEscape (ctx .Repo .Commit .ID .String ()), 1 ))))
977977 }
0 commit comments