feat: add .gitignore pattern support for repository analysis #35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR splits out a feature from the fork branch referenced in #28 as an initial contribution🙏
Welcome to review and provide suggestions. I'm happy to make adjustments as needed
TLDR
Adds support for respecting
.gitignorepatterns during repository analysis. Usesgit check-ignorewhen available with fallback to pathspec library.Examples:
Dive Deeper
Key Changes
repo_analyzer.py
_user_exclude_patternsto distinguish user-specified vs default excludesrespect_gitignore:_should_include_fileto use pathspec matching for include patternsanalysis_service.py
Nonechecks inanalyze_local_repositoryand_analyze_structureHow It Works
git check-ignorecommand for full recursive accuracy.gitignorematching.gitignorefiles, pattern negation (!pattern), and complex patterns.git,*.pyc,__pycache__/,node_modules/, etc.Exclusion priority:
--respect-gitignoreenabled and git says ignored) → exclude--exclude) → exclude.gitignorefile (if--respect-gitignoreenabled) → excludeUse cases:
node_modules/,build/,.env,*.log__pycache__/,*.pyc,.venv/,*.egg-info/.gitignorefile are respected.git/), caches, logs, and other standard patterns always excludedReviewer Test Plan Suggestions
1. Check Documentation
You can review the changes in
README.mdto verify accuracy and clarity:2. Verify Gitignore Behavior
You can run this script to verify hybrid strategy and priority logic:
The test script verifies:
Output:
Details
3. Runtime Check
You can verify the CLI configuration loads the flag correctly:
Output:
Details