-
Notifications
You must be signed in to change notification settings - Fork 848
feat(cli): add --include-gitignored
flag to exclude files listed in .gitignore
#253
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
@ArmanJR Thanks for your contribution, I've looked at the code and it looks OK, I would have to run some tests myself In order to merge this I think we would need to reflect those changes in the front-end so gitingest keeps 1-1 features no matter from where it is accessed Here's a rough sketch of how it could look like: Do you think you can handle this or do you want us to help you with that? |
I'll try :) |
Very useful feature! |
@cyclotruc I believe having the checkbox on UI is redundant, as the files on a GitHub repo are already ignored if mentioned in the |
@cyclotruc bump! |
Hi, sorry for the delay i've been busy but will come back to this soon, thanks again for your patience |
This will be a great feature. For me I expected this behaviour by default and was surprised to find some credentials in the |
Also, there is another issue in local ~/code/Go/sandbox ··········································································································· 10:39:58 AM
❯ echo "boz hi" > main.go
~/code/Go/sandbox ··········································································································· 10:40:18 AM
❯ cat main.go
boz hi
~/code/Go/sandbox ··········································································································· 10:40:21 AM
❯ gitingest ./
Analysis complete! Output written to: digest.txt
Summary:
Repository: ./
Files analyzed: 1
Estimated tokens: 29
❯ cat digest.txt
Directory structure:
└── .//
└── main.go
================================================
File: /main.go
================================================
boz hi
~/code/Go/sandbox ··········································································································· 10:40:32 AM
❯ gitingest ./
Analysis complete! Output written to: digest.txt
Summary:
Repository: ./
Files analyzed: 2
Estimated tokens: 73
~/code/Go/sandbox ··········································································································· 10:40:37 AM
❯ cat digest.txt
Directory structure:
└── .//
├── digest.txt
└── main.go
================================================
File: /digest.txt
================================================
Directory structure:
└── .//
└── main.go
================================================
File: /main.go
================================================
boz hi
================================================
File: /main.go
================================================
boz hi
I believe since users usually don't double-check the content of |
@ArmanJR The tests are failing. Can you have a look at it? |
@ArmanJR Thank you for the contribution |
--use-gitignore
flag to exclude files listed in .gitignore
Of course, I'd be happy to help. Is there anything else that should be implemented? |
Suggestion on flag semantics & naming
|
--use-gitignore
flag to exclude files listed in .gitignore
--include-gitignored
flag to exclude files listed in .gitignore
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.
This is wonderful!
I just tried it and it works like a charm,
thanks a lot @ArmanJR and @filipchristiansen, merging
Thanks a lot @ArmanJR! Just a follow up question: What was the reason for the version ( |
@filipchristiansen You mean why |
This pull request introduces a new CLI flag (
--use-gitignore
) that enhances Gitingest by automatically loading and applying ignore patterns from all.gitignore
files found in the target repository or directory. When enabled, files and directories matching any pattern specified in any.gitignore
are excluded from the generated text digest.Key Changes:
CLI Update:
src/gitingest/cli.py
to add a new option--use-gitignore
that accepts a boolean value.main()
function to pass the new flag to the asynchronous ingestion entry point.Ingestion Entry Point:
src/gitingest/entrypoint.py
to include a new parameteruse_gitignore
.load_gitignore_patterns()
(fromsrc/gitingest/utils/ignore_patterns.py
) to update the query’s ignore patterns with all patterns extracted from.gitignore
files.Gitignore Loader:
load_gitignore_patterns()
insrc/gitingest/utils/ignore_patterns.py
, which recursively searches for.gitignore
files starting from the repository root and aggregates their ignore patterns.Testing:
tests/test_gitignore_feature.py
to verify that:--use-gitignore
enabled, files matching.gitignore
patterns are excluded from the digest.This feature provides a seamless way to respect repository-level ignore rules, ensuring that the generated digest is more relevant for ingestion by large language models. It improves usability by reducing the need for manual pattern exclusions and aligns the tool’s behavior more closely with Git’s own ignore logic.