Skip to content

feat: add .gitnexusignore support#246

Closed
2233admin wants to merge 1 commit into
abhigyanpatwari:mainfrom
2233admin:feat/gitnexusignore-support
Closed

feat: add .gitnexusignore support#246
2233admin wants to merge 1 commit into
abhigyanpatwari:mainfrom
2233admin:feat/gitnexusignore-support

Conversation

@2233admin

Copy link
Copy Markdown

Summary

  • Adds .gitnexusignore file support (standard .gitignore syntax) to exclude files/directories from indexing
  • Uses the ignore npm package for pattern matching (glob, # comments, ! negation)
  • Patterns applied early in walkRepositoryPaths() before stat/read, for performance
  • Graceful fallback when no .gitnexusignore exists

Closes #228

Files changed

  • gitnexus/src/config/ignore-service.ts — new loadGitNexusIgnore() function
  • gitnexus/src/core/ingestion/filesystem-walker.ts — integrated ignore patterns into file discovery
  • gitnexus/package.json — added ignore dependency

Test plan

  • Create .gitnexusignore with patterns like node_modules/, *.generated.ts
  • Run gitnexus analyze and verify excluded files are not indexed
  • Verify no .gitnexusignore = no change in behavior
  • Verify ! negation patterns work

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Mar 11, 2026

Copy link
Copy Markdown

@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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: The JSDoc is fine on its own, but no other export in this file has one. Not a blocker — just flagging the inconsistency.

@jecanore

Copy link
Copy Markdown
Contributor

@2233admin, heads up — PR #301 also addresses .gitnexusignore (same ignore package approach) plus the unsupported language crash. Happy to coordinate if you'd like to review!

@magyargergo

Copy link
Copy Markdown
Collaborator

#231 already addressed this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support .gitignore / .gitnexusignore for excluding directories from indexing

4 participants