Skip to content

Commit

Permalink
don't try to interpret treepath as hash
Browse files Browse the repository at this point in the history
...when path contains no hash-path-separator ('/')

This is a workaround to go-gitea#17179.

Entering this case when `path` does not contain a '/' does not really
make sense, as that means the tree path is empty, but this case is only
entered for routes that expect a non-empty tree path.

Treepaths like <40-char-dirname>/<filename> will still fail,
but hopefully don't occur that often. A more complete fix that avoids
this case too is outlined in go-gitea#17185, but too big of a change to backport
  • Loading branch information
noerw committed Oct 8, 2021
1 parent 1c3ae6d commit e4d129d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
}
// For legacy and API support only full commit sha
parts := strings.Split(path, "/")
if len(parts) > 0 && len(parts[0]) == 40 {
if len(parts) > 1 && len(parts[0]) == 40 {
ctx.Repo.TreePath = strings.Join(parts[1:], "/")
return parts[0]
}
Expand Down

0 comments on commit e4d129d

Please sign in to comment.