@@ -807,7 +807,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
807807 }
808808 // For legacy and API support only full commit sha
809809 parts := strings .Split (path , "/" )
810- if len (parts ) > 0 && len (parts [0 ]) == 40 {
810+ if len (parts ) > 0 && len (parts [0 ]) == git . SHAFullLength {
811811 ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
812812 return parts [0 ]
813813 }
@@ -843,7 +843,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
843843 return getRefNameFromPath (ctx , path , ctx .Repo .GitRepo .IsTagExist )
844844 case RepoRefCommit :
845845 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 {
847847 ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
848848 return parts [0 ]
849849 }
@@ -952,7 +952,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
952952 return
953953 }
954954 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 {
956956 ctx .Repo .IsViewCommit = true
957957 ctx .Repo .CommitID = refName
958958
@@ -962,7 +962,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
962962 return
963963 }
964964 // If short commit ID add canonical link header
965- if len (refName ) < 40 {
965+ if len (refName ) < git . SHAFullLength {
966966 ctx .RespHeader ().Set ("Link" , fmt .Sprintf ("<%s>; rel=\" canonical\" " ,
967967 util .URLJoin (setting .AppURL , strings .Replace (ctx .Req .URL .RequestURI (), util .PathEscapeSegments (refName ), url .PathEscape (ctx .Repo .Commit .ID .String ()), 1 ))))
968968 }
0 commit comments