@@ -816,7 +816,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
816
816
}
817
817
// For legacy and API support only full commit sha
818
818
parts := strings .Split (path , "/" )
819
- if len (parts ) > 0 && len (parts [0 ]) == 40 {
819
+ if len (parts ) > 0 && len (parts [0 ]) == git . SHAFullLength {
820
820
ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
821
821
return parts [0 ]
822
822
}
@@ -852,7 +852,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
852
852
return getRefNameFromPath (ctx , path , ctx .Repo .GitRepo .IsTagExist )
853
853
case RepoRefCommit :
854
854
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 {
856
856
ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
857
857
return parts [0 ]
858
858
}
@@ -961,7 +961,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
961
961
return
962
962
}
963
963
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 {
965
965
ctx .Repo .IsViewCommit = true
966
966
ctx .Repo .CommitID = refName
967
967
@@ -971,7 +971,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
971
971
return
972
972
}
973
973
// If short commit ID add canonical link header
974
- if len (refName ) < 40 {
974
+ if len (refName ) < git . SHAFullLength {
975
975
ctx .RespHeader ().Set ("Link" , fmt .Sprintf ("<%s>; rel=\" canonical\" " ,
976
976
util .URLJoin (setting .AppURL , strings .Replace (ctx .Req .URL .RequestURI (), util .PathEscapeSegments (refName ), url .PathEscape (ctx .Repo .Commit .ID .String ()), 1 ))))
977
977
}
0 commit comments