Skip to content

fix: add --no-gitignore extraction opt-out#1979

Closed
Mzt00 wants to merge 2 commits into
Graphify-Labs:v8from
Mzt00:fix/no-gitignore
Closed

fix: add --no-gitignore extraction opt-out#1979
Mzt00 wants to merge 2 commits into
Graphify-Labs:v8from
Mzt00:fix/no-gitignore

Conversation

@Mzt00

@Mzt00 Mzt00 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds graphify extract <path> --no-gitignore for generated or transpiled source that is excluded from Git but still belongs in the graph. Fixes #1971

With the flag, Graphify:

  • skips root, ancestor, and nested .gitignore files;
  • skips $GIT_DIR/info/exclude;
  • still prioritizes .graphifyignore explicit --exclude patterns, noise filters, and sensitive-file checks; and
  • persists the setting for later update, watch, and hook rebuilds.

Default extraction behavior is unchanged.

Implementation

The detector APIs now accept a keyword-only gitignore: bool = True. The extract CLI passes False for both full and incremental scans when --no-gitignore is present.

The setting is stored in graphify-out/.graphify_build.json. Rebuild and watch paths read it before rescanning or filtering filesystem events, preventing generated files from disappearing after the initial extraction. Existing build configs without the key default to True.

Why .graphifyignore remains active

The staged loader change separates Graphify-owned rules from VCS-owned rules. With gitignore=False, _load_dir_own_ignore() loads only .graphifyignore; _load_graphifyignore() skips .git/info/exclude but still loads .graphifyignore at ancestor, root, and nested-directory anchors. detect() and watch/rebuild callers pass the same setting through every scan path.

The end-to-end test confirms this behavior: Git-ignored Gen.cs and Local.cs are included, while .graphifyignore-excluded Hidden.cs remains absent.

Behavior

Rule source Default --no-gitignore
.gitignore Applied Skipped
.git/info/exclude Applied Skipped
.graphifyignore Applied Applied
--exclude Applied Applied
Noise and sensitive-file filters Applied Applied

Tests and validation

  • End-to-end extraction verifies VCS-ignored C# is included while .graphifyignore remains active.
  • Rebuild coverage verifies the persisted setting continues to include generated code.
  • Existing tests guard default Git-ignore behavior and persisted explicit exclusions.
  • Ruff passed for all changed Python files.
  • Focused regression set: 7 passed.

safishamsi added a commit that referenced this pull request Jul 18, 2026
…-up to #1979)

The PR always wrote gitignore=not no_gitignore into .graphify_build.json, so a
flag-less `graphify extract` after `--no-gitignore` reset it to True and the
git-ignored code silently disappeared again — the exact #1971 complaint. Write
False only when the flag is set (None = leave as-is, mirroring #1886 excludes),
and honor the persisted value for the run when the flag is absent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Collaborator

Landed on v8 (ships in 0.9.19) in f17e2c5, cherry-picked to preserve your authorship. Thanks @MZT006 — --no-gitignore disables only VCS ignore rules while keeping .graphifyignore and the secret/sensitive screens. Follow-up added on top (caa6f9e): the setting now persists and is not clobbered back on by a later flag-less graphify extract, so git-ignored code does not silently disappear (the #1971 complaint).

@safishamsi safishamsi closed this Jul 18, 2026
@safishamsi

Copy link
Copy Markdown
Collaborator

Credit correction: this fix is by @Mzt00 (I earlier mistyped @MZT006, an unrelated user — apologies to them). Report was @JensD-git. Fixed in the changelog and 0.9.19 release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow extracting git-ignored code: add --no-gitignore opt-out

2 participants