@@ -807,7 +807,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
807
807
}
808
808
// For legacy and API support only full commit sha
809
809
parts := strings .Split (path , "/" )
810
- if len (parts ) > 0 && len (parts [0 ]) == 40 {
810
+ if len (parts ) > 0 && len (parts [0 ]) == git . SHAFullLength {
811
811
ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
812
812
return parts [0 ]
813
813
}
@@ -843,7 +843,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
843
843
return getRefNameFromPath (ctx , path , ctx .Repo .GitRepo .IsTagExist )
844
844
case RepoRefCommit :
845
845
parts := strings .Split (path , "/" )
846
- if len (parts ) > 0 && len (parts [0 ]) >= 7 && len (parts [0 ]) <= 40 {
846
+ if len (parts ) > 0 && len (parts [0 ]) >= 7 && len (parts [0 ]) <= git . SHAFullLength {
847
847
ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
848
848
return parts [0 ]
849
849
}
@@ -952,7 +952,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
952
952
return
953
953
}
954
954
ctx .Repo .CommitID = ctx .Repo .Commit .ID .String ()
955
- } else if len (refName ) >= 7 && len (refName ) <= 40 {
955
+ } else if len (refName ) >= 7 && len (refName ) <= git . SHAFullLength {
956
956
ctx .Repo .IsViewCommit = true
957
957
ctx .Repo .CommitID = refName
958
958
@@ -962,7 +962,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
962
962
return
963
963
}
964
964
// If short commit ID add canonical link header
965
- if len (refName ) < 40 {
965
+ if len (refName ) < git . SHAFullLength {
966
966
ctx .RespHeader ().Set ("Link" , fmt .Sprintf ("<%s>; rel=\" canonical\" " ,
967
967
util .URLJoin (setting .AppURL , strings .Replace (ctx .Req .URL .RequestURI (), util .PathEscapeSegments (refName ), url .PathEscape (ctx .Repo .Commit .ID .String ()), 1 ))))
968
968
}
0 commit comments