feat: add .gitnexusignore support#246
Conversation
Closes abhigyanpatwari#228. Users can create a .gitnexusignore file in their repo root using standard .gitignore syntax (glob patterns, comments, negation) to exclude directories and files from being indexed by the GitNexus analyzer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@2233admin is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
| return ig; | ||
| } catch { | ||
| // No .gitnexusignore file — that's fine, return null | ||
| return null; |
There was a problem hiding this comment.
major: This bare catch swallows all errors, not just "file not found". If .gitnexusignore exists but has permission issues, corrupt encoding, or a disk error, the failure is silently ignored — the user won't know their patterns weren't loaded.
Consider catching only ENOENT and re-throwing everything else:
} catch (err: unknown) {
if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
return null; // No .gitnexusignore file — that's fine
}
throw err; // Permission error, corrupt file, etc.
}| @@ -1,3 +1,25 @@ | |||
| import fs from 'fs'; | |||
There was a problem hiding this comment.
minor: This imports sync fs (readFileSync) while the rest of this file and filesystem-walker.ts use fs/promises (async). Since the caller (walkRepositoryPaths) is already async, using await fs.readFile() would be more consistent with the codebase style.
| // Load .gitnexusignore patterns (null if file doesn't exist) | ||
| const nexusIgnore = loadGitNexusIgnore(repoPath); | ||
|
|
||
| const filtered = files.filter(file => { |
There was a problem hiding this comment.
minor: loadGitNexusIgnore(repoPath) re-reads the file from disk on every call to walkRepositoryPaths. If the same analysis invokes the walker multiple times (e.g. incremental re-analysis), this is redundant I/O. Consider either memoizing the result or accepting an optional Ignore parameter so the caller can load it once and pass it in.
| import path from 'path'; | ||
| import ignore, { Ignore } from 'ignore'; | ||
|
|
||
| /** |
There was a problem hiding this comment.
nitpick: The JSDoc is fine on its own, but no other export in this file has one. Not a blocker — just flagging the inconsistency.
|
@2233admin, heads up — PR #301 also addresses |
|
#231 already addressed this |
Summary
.gitnexusignorefile support (standard.gitignoresyntax) to exclude files/directories from indexingignorenpm package for pattern matching (glob,#comments,!negation)walkRepositoryPaths()before stat/read, for performance.gitnexusignoreexistsCloses #228
Files changed
gitnexus/src/config/ignore-service.ts— newloadGitNexusIgnore()functiongitnexus/src/core/ingestion/filesystem-walker.ts— integrated ignore patterns into file discoverygitnexus/package.json— addedignoredependencyTest plan
.gitnexusignorewith patterns likenode_modules/,*.generated.tsgitnexus analyzeand verify excluded files are not indexed.gitnexusignore= no change in behavior!negation patterns work🤖 Generated with Claude Code