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