@@ -817,7 +817,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
817817 }
818818 // For legacy and API support only full commit sha
819819 parts := strings .Split (path , "/" )
820- if len (parts ) > 0 && len (parts [0 ]) == 40 {
820+ if len (parts ) > 0 && len (parts [0 ]) == git . SHAFullLength {
821821 ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
822822 return parts [0 ]
823823 }
@@ -853,7 +853,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
853853 return getRefNameFromPath (ctx , path , ctx .Repo .GitRepo .IsTagExist )
854854 case RepoRefCommit :
855855 parts := strings .Split (path , "/" )
856- if len (parts ) > 0 && len (parts [0 ]) >= 7 && len (parts [0 ]) <= 40 {
856+ if len (parts ) > 0 && len (parts [0 ]) >= 7 && len (parts [0 ]) <= git . SHAFullLength {
857857 ctx .Repo .TreePath = strings .Join (parts [1 :], "/" )
858858 return parts [0 ]
859859 }
@@ -962,7 +962,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
962962 return
963963 }
964964 ctx .Repo .CommitID = ctx .Repo .Commit .ID .String ()
965- } else if len (refName ) >= 7 && len (refName ) <= 40 {
965+ } else if len (refName ) >= 7 && len (refName ) <= git . SHAFullLength {
966966 ctx .Repo .IsViewCommit = true
967967 ctx .Repo .CommitID = refName
968968
@@ -972,7 +972,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
972972 return
973973 }
974974 // If short commit ID add canonical link header
975- if len (refName ) < 40 {
975+ if len (refName ) < git . SHAFullLength {
976976 ctx .RespHeader ().Set ("Link" , fmt .Sprintf ("<%s>; rel=\" canonical\" " ,
977977 util .URLJoin (setting .AppURL , strings .Replace (ctx .Req .URL .RequestURI (), util .PathEscapeSegments (refName ), url .PathEscape (ctx .Repo .Commit .ID .String ()), 1 ))))
978978 }
0 commit comments