Add CBM_EXTRA_SKIP_DIRS env var for site-specific always-skip directories#912
Open
chethanuk wants to merge 1 commit into
Open
Add CBM_EXTRA_SKIP_DIRS env var for site-specific always-skip directories#912chethanuk wants to merge 1 commit into
chethanuk wants to merge 1 commit into
Conversation
…p dirs Callers can skip extra directory names (comma-separated, whitespace-trimmed) during indexing without a rebuild, checked alongside the hardcoded ALWAYS_SKIP_DIRS in cbm_should_skip_dir. Applies in every mode. The env var is read through cbm_safe_getenv into a local buffer so the value is mt-safe (raw getenv's pointer can be invalidated by a concurrent setenv/putenv) and correct for UTF-8 on Windows. The repro test uses the portable cbm_setenv/cbm_unsetenv wrappers rather than raw POSIX setenv/unsetenv. Covered by a table-driven test that verifies baseline-discovered -> skipped-with-env-set (including a whitespace-padded CSV entry) -> discovered-again-after-unset. Signed-off-by: ChethanUK <chethanuk@outlook.com>
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.
What does this PR do?
Adds a
CBM_EXTRA_SKIP_DIRSenvironment variable so callers can skip extra,site-specific directory names during indexing without a rebuild.
Motivation. Prior AI-tooling output directories (
.codegraph/,graphify-out/,.wiki/,.understand-anything/) get walked and parsed assource during indexing, since none are in the universal skip list
(
ALWAYS_SKIP_DIRSinsrc/discover/discover.c) or in target repos' own.gitignore. Hardcoding these four names would fix only this case; the generalproblem is broader (a
.dbttarget dir, a Terraform state dir, etc.) and arebuild per new name does not scale.
What changed.
src/discover/discover.c:cbm_should_skip_dirnow also skips names listedin
CBM_EXTRA_SKIP_DIRS(comma-separated, whitespace-trimmed), checkedalongside the hardcoded list and applied in every mode. The truly universal
ALWAYS_SKIP_DIRSlist is left untouched. The value is read throughcbm_safe_getenvinto a local buffer — matching the rest of the codebase — soit is thread-safe (raw
getenv's pointer can be invalidated by a concurrentsetenv/putenv) and correct for UTF-8 environment values on Windows. TheCSV scan is non-mutating, so the copied buffer is never altered in place.
tests/repro/repro_invariant_discovery_fqn.c: adds table-driveninvariant_discovery_env_extra_skip_dirs— a name is discovered by default,skipped once
CBM_EXTRA_SKIP_DIRSlists it (including a whitespace-padded CSVentry to exercise trimming), and discovered again after the var is cleared,
proving the behavior is genuinely env-gated. Uses the portable
cbm_setenv/cbm_unsetenvwrappers so it also compiles on Windows.docs/cbmignore.md: documents the new opt-in.CBM_EXTRA_SKIP_DIRSis set bythe caller invoking indexing, not by the indexed repo, so it does not weaken
the "not overridable from a repo-local ignore file" guarantee.
How verified
str_in_env_csv/cbm_should_skip_dirinsrc/discover/discover.ccompileclean (
cc -fsyntax-only); the repro test translation unit compiles clean.baseline/skip/restore and whitespace-trimming cases (listed name skipped,
padded entries trimmed, substrings not matched, unset/empty env not skipped).
make -f Makefile.cbm testrequires the project toolchain; the newbehavior is covered by the table-driven repro test above.
Checklist
git commit -s)make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)