Fix glob pattern matching for extension patterns in .gptinclude/.gptignore files #21
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.
Problem
Users reported that git2gpt "doesn't produce output" or produces unexpected results when using extension patterns like
*.go
,*.log
, or*.tmp
in their.gptinclude
and.gptignore
files. The issue was that these patterns only matched files at the root level of the repository, not files in subdirectories.For example:
*.log
in.gptignore
would excludedebug.log
but notsrc/debug.log
orlogs/error.log
*.go
in.gptinclude
would includemain.go
but notsrc/main.go
orpkg/utils.go
This caused confusion where users expected these patterns to work recursively throughout their repository but they only worked for root-level files.
Solution
Modified the pattern processing logic in
getIncludeList()
andgetIgnoreList()
functions to automatically expand simple extension patterns like*.ext
into two patterns:*.ext
- matches root-level files (e.g.,main.go
)**/*.ext
- matches nested files (e.g.,src/main.go
,deep/nested/file.go
)This ensures that when users write
*.go
in their configuration files, it matches ALL.go
files throughout the repository, which aligns with user expectations.Example
Before this fix:
After this fix:
Backward Compatibility
**
(like**/*.json
) continue to work exactly as beforesrc/
) are unaffectedsrc/*.go
) are unaffected*.ext
) are expandedTesting
This change makes git2gpt's pattern matching behavior intuitive and consistent with user expectations while maintaining full backward compatibility.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
openaipublic.blob.core.windows.net
/tmp/go-build2354109801/b206/cmd.test -test.testlogfile=/tmp/go-build2354109801/b206/testlog.txt -test.paniconexit0 -test.timeout=10m0s
(dns block)/tmp/go-build2354109801/b220/prompt.test -test.testlogfile=/tmp/go-build2354109801/b220/testlog.txt -test.paniconexit0 -test.timeout=10m0s
(dns block)./git2gpt .
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.