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)
| 71 | // "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so |
| 72 | // deletions were misclassified and triggered a doomed `git show ref:path`. |
| 73 | func TestParseDiffText_DeletedFile(t *testing.T) { |
| 74 | diffText := `diff --git a/gone.go b/gone.go |
| 75 | deleted file mode 100644 |
| 76 | index 1234567..0000000 |
| 77 | --- a/gone.go |
| 78 | +++ /dev/null |
| 79 | @@ -1,2 +0,0 @@ |
| 80 | -line1 |
| 81 | -line2 |
| 82 | ` |
| 83 | diffs, err := ParseDiffText(context.Background(), diffText, t.TempDir(), "", nil) |
| 84 | if err != nil { |
| 85 | t.Fatalf("ParseDiffText: %v", err) |
| 86 | } |
| 87 | if len(diffs) != 1 { |
| 88 | t.Fatalf("expected 1 diff, got %d", len(diffs)) |
| 89 | } |
| 90 | d := diffs[0] |
| 91 | if !d.IsDeleted { |
| 92 | t.Errorf("IsDeleted = false, want true") |
| 93 | } |
| 94 | if d.NewPath != "/dev/null" { |
| 95 | t.Errorf("NewPath = %q, want /dev/null", d.NewPath) |
| 96 | } |
| 97 | if d.OldPath != "gone.go" { |
| 98 | t.Errorf("OldPath = %q, want gone.go", d.OldPath) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix). |
| 103 | func TestParseDiffText_NewFile(t *testing.T) { |
nothing calls this directly
no test coverage detected