mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 04:05:42 +01:00
Merge pull request '[v8.0/forgejo] [BUG] Allow 4 charachter SHA in /src/commit
' (#4840) from bp-v8.0/forgejo-b967fce into v8.0/forgejo
Some checks are pending
/ release (push) Waiting to run
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (push) Blocked by required conditions
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:redis:7.2 port:6379]) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Some checks are pending
/ release (push) Waiting to run
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (push) Blocked by required conditions
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:redis:7.2 port:6379]) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4840 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
commit
6904b833e1
2 changed files with 9 additions and 2 deletions
|
@ -897,7 +897,7 @@ func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string {
|
|||
case RepoRefCommit:
|
||||
parts := strings.Split(path, "/")
|
||||
|
||||
if len(parts) > 0 && len(parts[0]) >= 7 && len(parts[0]) <= repo.GetObjectFormat().FullLength() {
|
||||
if len(parts) > 0 && len(parts[0]) >= 4 && len(parts[0]) <= repo.GetObjectFormat().FullLength() {
|
||||
repo.TreePath = strings.Join(parts[1:], "/")
|
||||
return parts[0]
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
|
|||
return cancel
|
||||
}
|
||||
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
|
||||
} else if len(refName) >= 7 && len(refName) <= ctx.Repo.GetObjectFormat().FullLength() {
|
||||
} else if len(refName) >= 4 && len(refName) <= ctx.Repo.GetObjectFormat().FullLength() {
|
||||
ctx.Repo.IsViewCommit = true
|
||||
ctx.Repo.CommitID = refName
|
||||
|
||||
|
|
|
@ -710,6 +710,13 @@ func TestCommitView(t *testing.T) {
|
|||
doc := NewHTMLParser(t, resp.Body)
|
||||
commitTitle := doc.Find(".commit-summary").Text()
|
||||
assert.Contains(t, commitTitle, "Initial commit")
|
||||
|
||||
req = NewRequest(t, "GET", "/user2/repo1/src/commit/65f1")
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
doc = NewHTMLParser(t, resp.Body)
|
||||
commitTitle = doc.Find(".shortsha").Text()
|
||||
assert.Contains(t, commitTitle, "65f1bf27bc")
|
||||
})
|
||||
|
||||
t.Run("Full commit ID", func(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue