Skip to content

Comments

Make .blarignore additive to .gitignore for automatic exclusion#7

Merged
rysweet merged 1 commit intomainfrom
feature/gitignore-integration-6
Jul 30, 2025
Merged

Make .blarignore additive to .gitignore for automatic exclusion#7
rysweet merged 1 commit intomainfrom
feature/gitignore-integration-6

Conversation

@rysweet
Copy link
Owner

@rysweet rysweet commented Jul 30, 2025

Summary

This PR implements automatic .gitignore support in Blarify, making .blarignore additive to .gitignore patterns. This ensures that files ignored by git (like node_modules, .env, build artifacts) are automatically excluded from the graph analysis.

Changes

  • ✅ Added pathspec dependency for proper gitignore pattern parsing
  • ✅ Created GitignoreManager class to handle .gitignore file parsing and caching
  • ✅ Modified ProjectFilesIterator to support gitignore integration
  • ✅ Updated GraphBuilder API to expose gitignore configuration options
  • ✅ Added comprehensive test suite covering various gitignore scenarios
  • ✅ Updated documentation with gitignore feature details

Benefits

  • 🚀 Automatic exclusion of git-ignored files
  • 🔄 Reduced maintenance burden (no need to duplicate patterns)
  • ⚡ Better performance by skipping unnecessary files
  • 🎯 Consistent behavior with git

How it works

  1. Automatic loading: All .gitignore files in the project are automatically found and parsed
  2. Additive behavior: .blarignore adds additional exclusions on top of .gitignore
  3. Full pattern support: Supports all gitignore syntax including globs, negations*, and comments
  4. Configurable: Can be disabled if needed via use_gitignore=False

*Note: Complex negation patterns (e.g., \!build/keep/) are not fully supported yet and will be addressed in a follow-up PR.

Testing

  • ✅ Files in .gitignore are excluded
  • .blarignore patterns work additively
  • ✅ Nested .gitignore files are respected
  • ✅ Feature can be disabled
  • ⏭️ Negation patterns (marked as skip, to be addressed later)

Example Usage

# Gitignore support is enabled by default
graph_builder = GraphBuilder(root_path="/path/to/project")

# Or explicitly configure
graph_builder = GraphBuilder(
    root_path="/path/to/project",
    use_gitignore=True,  # Default
    blarignore_path="/custom/path/.blarignore"  # Optional
)

Fixes #6

- Add pathspec dependency for proper gitignore pattern parsing
- Create GitignoreManager class to handle .gitignore file parsing
- Modify ProjectFilesIterator to support gitignore integration
- Update GraphBuilder API to expose gitignore configuration
- Add comprehensive test suite for gitignore functionality
- Update documentation with gitignore feature details

This change ensures that files ignored by git (like node_modules, .env,
build artifacts) are automatically excluded from Blarify's graph analysis.
The .blarignore file now adds additional exclusions on top of .gitignore
patterns, reducing duplication and maintenance burden.

Fixes #6
@rysweet rysweet merged commit b3fca66 into main Jul 30, 2025
rysweet pushed a commit that referenced this pull request Aug 3, 2025
fix: add parent parameter and node_repr_for_identifier property to No…
rysweet added a commit that referenced this pull request Aug 3, 2025
Make .blarignore additive to .gitignore for automatic exclusion
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.

Make .blarignore additive to .gitignore for automatic exclusion of git-ignored files

1 participant