vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Open a deleted file instead of failing the page
bef0c093da662024c936eb2c230cf2a3521ecbb9 · Keenan Nemetz · 8d ago · parent f64c77e4
Open a deleted file instead of failing the page A deletion has an old path and no new one, and pathspec returned both sides to git. Git refuses an empty pathspec outright, so opening a deleted file on a commit page answered 500 and the file could not be reviewed at all. The per-file read this branch gives the Files tab would have extended that to every deleted file in a change. Return one path for a deletion, both only for a rename, and none when a row has no paths at all. No paths means there is no patch to ask for, which is not the same as every path: callers stop before asking git instead of printing the whole commit into a single file's pane. TestPathspecNamesTheSideThatExists pins the four shapes, and TestCommitPageShowsADeletedFile is the page that used to 500. The request Files test now carries a deletion too, and opens it.
server/web/diff_test.go +34
| @@ -195,3 +195,37 @@ func TestDiffSummary(t *testing.T) { | |||
| 195 | 195 | t.Fatalf("summary = +%d −%d, want +2 −3", added, removed) | |
| 196 | 196 | } | |
| 197 | 197 | } | |
| 198 | |||
| 199 | // TestPathspecNamesTheSideThatExists: git refuses an empty pathspec, and a | ||
| 200 | // deletion has only an old side. Handing it both sides used to fail the page for | ||
| 201 | // any deleted file; handing it none would print the whole commit instead. | ||
| 202 | func TestPathspecNamesTheSideThatExists(t *testing.T) { | ||
| 203 | t.Parallel() | ||
| 204 | cases := []struct { | ||
| 205 | name string | ||
| 206 | file diffFile | ||
| 207 | want []string | ||
| 208 | }{ | ||
| 209 | {"modified", diffFile{OldPath: "a.go", NewPath: "a.go"}, []string{"a.go"}}, | ||
| 210 | {"added", diffFile{NewPath: "a.go"}, []string{"a.go"}}, | ||
| 211 | {"deleted", diffFile{OldPath: "a.go"}, []string{"a.go"}}, | ||
| 212 | {"renamed", diffFile{OldPath: "old.go", NewPath: "new.go"}, []string{"old.go", "new.go"}}, | ||
| 213 | {"unset", diffFile{}, nil}, | ||
| 214 | } | ||
| 215 | for _, tc := range cases { | ||
| 216 | t.Run(tc.name, func(t *testing.T) { | ||
| 217 | got := tc.file.pathspec() | ||
| 218 | if len(got) != len(tc.want) { | ||
| 219 | t.Fatalf("pathspec = %q, want %q", got, tc.want) | ||
| 220 | } | ||
| 221 | for i := range got { | ||
| 222 | if got[i] != tc.want[i] { | ||
| 223 | t.Fatalf("pathspec = %q, want %q", got, tc.want) | ||
| 224 | } | ||
| 225 | if got[i] == "" { | ||
| 226 | t.Fatalf("pathspec holds an empty path: %q", got) | ||
| 227 | } | ||
| 228 | } | ||
| 229 | }) | ||
| 230 | } | ||
| 231 | } | ||