-
-
Notifications
You must be signed in to change notification settings - Fork 279
feat: add .cgrignore file support for custom exclude patterns #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add support for a `.cgrignore` file that allows users to specify additional directories to exclude from parsing. Patterns from this file are merged with `--exclude` CLI flags and auto-detected directories. - Add `load_cgrignore_patterns()` function in config.py - Integrate with `prompt_exclude_directories()` in main.py - Add EXCLUDE_STATUS_CGRIGNORE constant for UI display - Add tests for .cgrignore loading - Update README with documentation
Addresses PR review feedback: - Move loguru import to module level in config.py - Use log constants from logs.py instead of f-strings
Summary of ChangesHello @vitali87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the directory exclusion capabilities by introducing support for a Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for a .cgrignore file, allowing users to specify custom exclusion patterns for directory parsing. The implementation is clean, well-tested, and properly documented in the README. The new load_cgrignore_patterns function correctly handles file parsing, including comments and blank lines, and integrates smoothly into the existing configuration for excluded directories. The addition of unit tests for this new functionality is a great practice.
My feedback includes a couple of suggestions to enhance robustness: one to make the file check more specific in config.py, and another to add a test case for an edge scenario where .cgrignore might be a directory. Overall, this is a solid contribution that improves the tool's configurability.
Greptile SummaryAdded support for a Key changes:
Integration notes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CLI
participant main
participant config
participant path_utils
participant filesystem
User->>CLI: cgr start --interactive-setup
CLI->>main: prompt_for_included_directories(repo_path, cli_excludes)
main->>main: detect_excludable_directories(repo_path)
main-->>main: detected directories (e.g., .git, node_modules)
main->>config: load_cgrignore_patterns(repo_path)
config->>filesystem: check if .cgrignore exists
alt .cgrignore exists
config->>filesystem: read .cgrignore file
filesystem-->>config: file content
config->>config: parse lines (strip whitespace, skip comments)
config-->>main: frozenset of patterns (e.g., vendor, my_build)
else .cgrignore not found
config-->>main: empty frozenset
end
main->>main: merge cli_patterns | cgrignore_patterns
main->>main: merge detected | pre_excluded
main->>main: group paths by pattern
main->>User: display grouped table
User->>main: select patterns to keep/exclude
main-->>CLI: frozenset of excluded directories
CLI->>path_utils: should_skip_path(path, exclude_paths)
path_utils->>path_utils: check if any path part in exclude_paths
path_utils-->>CLI: true/false
|
…tory edge case test
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for a .cgrignore file, allowing users to specify custom directories to exclude from parsing. The implementation is solid, including documentation updates in the README, new logic to load and merge ignore patterns, and comprehensive unit tests for the new functionality. My review includes a couple of suggestions for improvement: one to align with PEP 8 import conventions for better code style, and another to simplify and improve the robustness of a unit test. Overall, this is a well-executed feature addition.
Summary
Add support for a
.cgrignorefile that allows users to specify additional directories to exclude from parsing, similar to.gitignorebut simpler..cgrignoreare merged with--excludeCLI flags and auto-detected directories#comments, blank lines ignoredRebased from PR #219 (from @jxstanford's fork) to integrate with the new
--interactive-setupfeature from PR #221.Changes
codebase_rag/config.py: Addload_cgrignore_patterns()function andCGRIGNORE_FILENAMEconstantcodebase_rag/main.py: Integrate.cgrignoreloading intoprompt_for_included_directories()codebase_rag/constants.py: AddINTERACTIVE_STATUS_CGRIGNOREfor UI displaycodebase_rag/logs.py: Add log message templatescodebase_rag/tests/test_cgrignore.py: Add 6 unit testsREADME.md: Document the featureExample
.cgrignoreTest plan
pytest codebase_rag/tests/test_cgrignore.py).cgrignorefile in a repositoryCloses #219