Repository navigation
fix(indexer): root-anchor .cgcignore patterns containing a slash (#1513) - #1614
Merged
Merged
Conversation
Under gitignore semantics a slash anywhere except the trailing position anchors a pattern to the ignore root, so `src/generated` matches only <root>/src/generated. Here only a *leading* slash anchored; every other pattern got the match-at-any-depth prefix, so `src/generated` also ignored vendor/src/generated. Copying a line from .gitignore into .cgcignore -- the workflow the docs encourage -- therefore over-ignored, dropping real source from the index with no warning. A trailing slash is not an internal slash: `build/` has it stripped as is_dir_only before the check, so directory patterns keep matching at any depth, as gitignore does. All 16 new expectations were cross-checked against `git check-ignore` across 7 patterns. Fixes #1513. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ |
Contributor
🔍 PR Code Graph Analysisfix(indexer): root-anchor .cgcignore patterns containing a slash (#1513) (#1614) 📊 Interactive VisualizationView the blast radius graph: PR Reviewer Dashboard 📦 ArtifactsThe graph JSON has been uploaded as a build artifact: Generated by CodeGraphContext using FalkorDB Lite |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1513.
.cgcignoreis documented as using.gitignoresyntax, but only a leading slash anchored. Every other pattern got the match-at-any-depth prefix, so a multi-segment pattern over-matched:Under gitignore semantics a slash anywhere except the trailing position anchors the pattern to the ignore root. So copying a line out of
.gitignore— the workflow the docs encourage, and the point of #729 — silently dropped real source from the index with no warning.The fix
One condition: after the leading
/and trailing/have already been stripped, if a slash remains, anchor.The trailing-slash case is what makes this safe:
build/has its slash removed asis_dir_onlybefore the check, so directory patterns keep matching at any depth, exactly as gitignore does. Similarly**/diststays depth-independent because the leading**compiles to(?:.*/)?, which absorbs the anchor.Verification against real git
Every expectation was cross-checked against
git check-ignorein a scratch repo — 7 patterns × 17 paths, output identical:src/generatedsrc/generated/a.pysrc/generatedvendor/src/generated/a.pybuild/build/a.py,sub/build/a.pybuild/layout/a.py/foofoo/a.py/foobar/foo/a.pynode_modulesnode_modules/x.js,web/node_modules/x.js**/distdist/a.js,web/dist/a.jsdocs/**docs/a.mddocs/**vendor/docs/a.md,docstring.pya/**/ba/b/f.py,a/x/y/b/f.pya/**/bz/a/b/f.pyTests
16 parametrized cases added to
test_cgcignore_patterns.py. Verified the three over-ignoring cases fail onmainand all 16 pass with the fix.