From 17560eccb2d0551126148afac615bea99c03f00c Mon Sep 17 00:00:00 2001 From: ivkond Date: Mon, 6 Apr 2026 01:18:43 +0300 Subject: [PATCH] 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) --- gitnexus/src/config/ignore-service.ts | 4 +++- gitnexus/test/unit/ignore-service.test.ts | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gitnexus/src/config/ignore-service.ts b/gitnexus/src/config/ignore-service.ts index 29dda57d0..ce0771dd3 100644 --- a/gitnexus/src/config/ignore-service.ts +++ b/gitnexus/src/config/ignore-service.ts @@ -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; diff --git a/gitnexus/test/unit/ignore-service.test.ts b/gitnexus/test/unit/ignore-service.test.ts index 6c99cdbae..8a685129d 100644 --- a/gitnexus/test/unit/ignore-service.test.ts +++ b/gitnexus/test/unit/ignore-service.test.ts @@ -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);