loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: disallow blame on directories (#6716)

- Don't allow the blame operation on directories.
- Added integration test.
- Resolves forgejo/forgejo#6533

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6716
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>

authored by

Gusted
Gusted
and committed by
Gusted
fd285bfc b69755b4

+17
+5
routers/web/repo/blame.go
··· 56 56 HandleGitError(ctx, "Repo.Commit.GetTreeEntryByPath", err) 57 57 return 58 58 } 59 + if entry.IsDir() { 60 + ctx.NotFound("Cannot blame directory", nil) 61 + return 62 + } 63 + 59 64 blob := entry.Blob() 60 65 61 66 ctx.Data["PageIsViewCode"] = true
+12
tests/integration/repo_test.go
··· 1462 1462 htmlDoc.AssertElement(t, fmt.Sprintf(`tr[data-entryname="repo1"] a[href="%s"]`, u.JoinPath("/user2/repo1").String()), true) 1463 1463 }) 1464 1464 } 1465 + 1466 + func TestBlameDirectory(t *testing.T) { 1467 + defer tests.PrepareTestEnv(t)() 1468 + 1469 + // Ensure directory exists. 1470 + req := NewRequest(t, "GET", "/user2/repo59/src/branch/master/deep") 1471 + MakeRequest(t, req, http.StatusOK) 1472 + 1473 + // Blame is not allowed 1474 + req = NewRequest(t, "GET", "/user2/repo59/blame/branch/master/deep") 1475 + MakeRequest(t, req, http.StatusNotFound) 1476 + }