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)
| 116 | // "+++ /dev/null" WITHOUT the b/ prefix, which the old regexes required, so |
| 117 | // deletions were misclassified and triggered a doomed `git show ref:path`. |
| 118 | func TestParseDiffText_DeletedFile(t *testing.T) { |
| 119 | diffText := `diff --git a/gone.go b/gone.go |
| 120 | deleted file mode 100644 |
| 121 | index 1234567..0000000 |
| 122 | --- a/gone.go |
| 123 | +++ /dev/null |
| 124 | @@ -1,2 +0,0 @@ |
| 125 | -line1 |
| 126 | -line2 |
| 127 | ` |
| 128 | diffs, err := ParseDiffText(context.Background(), diffText, t.TempDir(), "", nil) |
| 129 | if err != nil { |
| 130 | t.Fatalf("ParseDiffText: %v", err) |
| 131 | } |
| 132 | if len(diffs) != 1 { |
| 133 | t.Fatalf("expected 1 diff, got %d", len(diffs)) |
| 134 | } |
| 135 | d := diffs[0] |
| 136 | if !d.IsDeleted { |
| 137 | t.Errorf("IsDeleted = false, want true") |
| 138 | } |
| 139 | if d.NewPath != "/dev/null" { |
| 140 | t.Errorf("NewPath = %q, want /dev/null", d.NewPath) |
| 141 | } |
| 142 | if d.OldPath != "gone.go" { |
| 143 | t.Errorf("OldPath = %q, want gone.go", d.OldPath) |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // TestParseDiffText_NewFile covers "--- /dev/null" (no a/ prefix). |
| 148 | func TestParseDiffText_NewFile(t *testing.T) { |
nothing calls this directly
no test coverage detected