Commit 2fcb428
Fix cachedGitignore cache-key correctness
Address PR #215 review (thread on internal/fix/fix.go:65): the
previous "drop the Abs error fallback" simplification was wrong —
filepath.Abs returns "" on failure (not the input string), so on
the rare error path every relative dir would collide on the empty
cache key and share one matcher across unrelated directories. My
preceding comment also misdescribed Abs's error semantics.
Fix the right way: don't normalize the cache key at all.
lint.NewGitignoreMatcher does its own filepath.Abs internally to
root the matcher, so the cache key only needs to be deterministic
across calls within a Fix run, which prepareFile already
guarantees by passing the same form (filepath.Dir(path) or
f.RootDir). Use the dir string verbatim and update the comment to
match what the code actually does.
Add TestFixer_CachedGitignore_DistinctKeys documenting the cache
contract: distinct inputs yield distinct matchers, repeated input
hits the cache, empty-string input is its own entry rather than
aliasing with everything else.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d6a4890 commit 2fcb428
2 files changed
Lines changed: 45 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
| 60 | + | |
62 | 61 | | |
63 | 62 | | |
64 | | - | |
65 | | - | |
| 63 | + | |
| 64 | + | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
164 | 196 | | |
165 | 197 | | |
166 | 198 | | |
| |||
0 commit comments