Load .gitignore contents relative to their location#262
Conversation
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 1f0e41e |
⏱️ Benchmark Resultsgatsby install-full-cold
📊 Raw benchmark data (gatsby install-full-cold)Base times: 2.714s, 2.708s, 2.580s, 2.526s, 2.572s, 2.560s, 2.511s, 2.537s, 2.522s, 2.544s, 2.629s, 2.503s, 2.552s, 2.535s, 2.540s, 2.546s, 2.476s, 2.556s, 2.557s, 2.491s, 2.400s, 2.353s, 2.501s, 2.590s, 2.466s, 2.581s, 2.585s, 2.530s, 2.600s, 2.600s Head times: 2.518s, 2.503s, 2.495s, 2.557s, 2.569s, 2.579s, 2.464s, 2.438s, 2.475s, 2.522s, 2.454s, 2.479s, 2.472s, 2.596s, 2.528s, 2.565s, 2.553s, 2.549s, 2.472s, 2.486s, 2.392s, 2.466s, 2.497s, 2.504s, 2.488s, 2.600s, 2.432s, 2.437s, 2.424s, 2.371s gatsby install-cache-and-lock (warm, with lockfile)
📊 Raw benchmark data (gatsby install-cache-and-lock (warm, with lockfile))Base times: 0.445s, 0.436s, 0.431s, 0.435s, 0.432s, 0.437s, 0.435s, 0.436s, 0.431s, 0.432s, 0.435s, 0.432s, 0.439s, 0.435s, 0.442s, 0.435s, 0.435s, 0.434s, 0.436s, 0.439s, 0.438s, 0.439s, 0.437s, 0.440s, 0.436s, 0.438s, 0.437s, 0.437s, 0.437s, 0.439s Head times: 0.440s, 0.444s, 0.441s, 0.438s, 0.443s, 0.437s, 0.443s, 0.448s, 0.441s, 0.472s, 0.441s, 0.440s, 0.442s, 0.441s, 0.438s, 0.443s, 0.440s, 0.483s, 0.437s, 0.433s, 0.433s, 0.431s, 0.436s, 0.436s, 0.433s, 0.432s, 0.434s, 0.436s, 0.435s, 0.438s |
|
Looks good; do you think you could add a test? If you only run that one it probably won't crash on git or anything |
25eace1 to
93cf3c8
Compare
93cf3c8 to
1f0e41e
Compare
|
Done, sorry for the wait I was out of the country for a few days ^^ |
| await run(`install`); | ||
|
|
||
| const {stdout} = await run(`pack`, `--dry-run`); | ||
| expect(stdout).toMatch(/index\.js/); |
There was a problem hiding this comment.
First assertion matches subdirectory path as a substring
/index\.js/ will also match the string subdir/index.js (because index.js appears as a substring). The two assertions together still correctly validate the intended behaviour — the second one guarantees subdir/index.js is absent, so the first one in practice can only be satisfied by the root-level file. However, if the root index.js were accidentally excluded while subdir/index.js was kept, the test would still pass (both assertions satisfied: "index.js" present as a substring of "subdir/index.js", and the literal "subdir/index.js" not present — wait, that contradicts; actually it would fail the second assertion). The subtle risk is that a future developer reading only the first assertion might think it exclusively verifies the root file. Using a more anchored pattern makes the intent explicit:
| expect(stdout).toMatch(/index\.js/); | |
| expect(stdout).toMatch(/(?<![/\\])index\.js/); |
Or alternatively, assert on the full relative path that should be present:
| expect(stdout).toMatch(/index\.js/); | |
| expect(stdout).toMatch(/\bindex\.js\b/); | |
| expect(stdout).toMatch(/index\.js/); // root-level file included |
This is a minor style concern — the test is functionally correct as-is.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js
Line: 294
Comment:
**First assertion matches subdirectory path as a substring**
`/index\.js/` will also match the string `subdir/index.js` (because `index.js` appears as a substring). The two assertions together still correctly validate the intended behaviour — the second one guarantees `subdir/index.js` is absent, so the first one in practice can only be satisfied by the root-level file. However, if the root `index.js` were accidentally excluded while `subdir/index.js` was kept, the test would still pass (both assertions satisfied: "index.js" present as a substring of "subdir/index.js", and the literal "subdir/index.js" not present — wait, that contradicts; actually it would fail the second assertion). The subtle risk is that a future developer reading only the first assertion might think it exclusively verifies the root file. Using a more anchored pattern makes the intent explicit:
```suggestion
expect(stdout).toMatch(/(?<![/\\])index\.js/);
```
Or alternatively, assert on the full relative path that *should* be present:
```suggestion
expect(stdout).toMatch(/\bindex\.js\b/);
expect(stdout).toMatch(/index\.js/); // root-level file included
```
This is a minor style concern — the test is functionally correct as-is.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
None of the suggested changes solve the "problem"
Currently
yarn packincorrectly applies a*gitignore pattern in repos that use Husky, since/.husky/_/.gitignoreis loaded as if it's/.gitignore75% of tests fail on my machine, including a bunch of tests that are stuck on git commit timing out trying to sign stuff, so I'll have to figure that out before I can fix any tests this PR breaks.