TestParseDiffText_DeletedFile guards the /dev/null detection: git emits "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so deletions were misclassified and triggered a doomed `git show ref:path`.
(t *testing.T)
| 182 | // "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so |
| 183 | // deletions were misclassified and triggered a doomed `git show ref:path`. |
| 184 | func TestParseDiffText_DeletedFile(t *testing.T) { |
| 185 | diffText := `diff --git a/gone.go b/gone.go |
| 186 | deleted file mode 100644 |
| 187 | index 1234567..0000000 |
| 188 | --- a/gone.go |
| 189 | +++ /dev/null |
| 190 | @@ -1,2 +0,0 @@ |
| 191 | -line1 |
| 192 | -line2 |
| 193 | ` |
| 194 | diffs, err := ParseDiffText(context.Background(), diffText, t.TempDir(), "", nil) |
| 195 | if err != nil { |
| 196 | t.Fatalf("ParseDiffText: %v", err) |
| 197 | } |
| 198 | if len(diffs) != 1 { |
| 199 | t.Fatalf("expected 1 diff, got %d", len(diffs)) |
| 200 | } |
| 201 | d := diffs[0] |
| 202 | if !d.IsDeleted { |
| 203 | t.Errorf("IsDeleted = false, want true") |
| 204 | } |
| 205 | if d.NewPath != "/dev/null" { |
| 206 | t.Errorf("NewPath = %q, want /dev/null", d.NewPath) |
| 207 | } |
| 208 | if d.OldPath != "gone.go" { |
| 209 | t.Errorf("OldPath = %q, want gone.go", d.OldPath) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix). |
| 214 | func TestParseDiffText_NewFile(t *testing.T) { |
nothing calls this directly
no test coverage detected