docs(ignore): link ignore package docs for bare-name normalization

Adds references to the `ignore` package documentation in both the
childrenIgnored comment and the bare-negation test, explaining why
`!iOS` (without trailing slash) also re-includes the iOS/ directory.

Addresses non-blocking review suggestion on #654.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
ivkond 2026-04-06 01:18:43 +03:00
parent 91b88202de
commit 17560eccb2
2 changed files with 6 additions and 3 deletions

View file

@ -402,7 +402,9 @@ export const createIgnoreFilter = async (repoPath: string, options?: IgnoreOptio
// a trailing slash. This ensures directory-only negation patterns (e.g.
// `!iOS/`) are applied correctly — without the slash, `ig.ignores('iOS')`
// treats the path as a file and misses the negation.
// Bare-name patterns (e.g. `local`) still match `local/` per gitignore spec.
// Bare-name patterns (e.g. `local`) still match `local/` per gitignore spec:
// the `ignore` package normalizes `dir` and `dir/` to match directories.
// See: https://github.com/kaelzhang/node-ignore#2-filenames-and-dirnames
if (ig) {
const rel = p.relative();
if (rel && ig.ignores(rel + '/')) return true;

View file

@ -364,8 +364,9 @@ describe('createIgnoreFilter', () => {
it('childrenIgnored respects negation patterns without trailing slash (!dir vs !dir/)', async () => {
// Per gitignore spec: `!iOS` (no slash) negates both files and directories
// named `iOS`, while `!iOS/` is directory-only. The `ignore` package should
// normalize both forms so that `ig.ignores('iOS/')` returns false in either case.
// named `iOS`, while `!iOS/` is directory-only. The `ignore` package
// normalizes both forms so that `ig.ignores('iOS/')` returns false in either case.
// Ref: https://github.com/kaelzhang/node-ignore#2-filenames-and-dirnames (see #596)
await fs.writeFile(path.join(tmpDir, '.gitnexusignore'), '*\n!iOS\n!iOS/**\n');
const filter = await createIgnoreFilter(tmpDir);