feat: auto-ignore .codemap/ when setting up codemap in a repo#80
Open
JordanCoin wants to merge 1 commit into
Open
feat: auto-ignore .codemap/ when setting up codemap in a repo#80JordanCoin wants to merge 1 commit into
JordanCoin wants to merge 1 commit into
Conversation
codemap writes its runtime state to `.codemap/`, but never told git to ignore it — so every project a user ran codemap in would leak `.codemap/` into commits unless they added the rule by hand. Add `ensureCodemapIgnored(root, mode)`: - No-op if git already ignores `.codemap/` (checked via `git check-ignore`, so it honors global excludes, existing rules, and negations). - `ignoreTracked` writes `.codemap/` to the repo's tracked `.gitignore` (team convention); `ignoreLocal` writes to `<git-common-dir>/info/exclude` (local-only, no tracked diff, shared across worktrees). - Silent no-op outside a git work tree; creates the file if missing; preserves existing content and trailing newline; never double-appends. Wire the tracked tier into `config init` and `setup` via a shared `reportEnsureIgnored` seam that prints a one-line notice on write. Tested first (TDD): ensureCodemapIgnored across write/no-op/create/append/ local/non-git cases, plus the reporting seam. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Problem
codemap writes all its runtime state to
.codemap/(config, event log, watch PID, handoffs, hub cache) — but it never tells git to ignore that directory. This repo's own.gitignorehas.codemap/only because it was added by hand. Every other project a user runs codemap in gets an unprotected.codemap/that they'll accidentally commit.This came out of a discussion about how codemap should behave across git worktrees: because
.codemap/is (correctly) per-working-directory runtime state, the tool should own making sure its own footprint is ignored — per git root, across worktrees and nested repos.What this does
New
ensureCodemapIgnored(root, mode)helper:.codemap/— checked viagit check-ignore, so it honors global excludes, existing.gitignorerules, and negations. No duplicate lines.ignoreTracked→ writes.codemap/to the repo's tracked.gitignore(team convention; every clone/worktree inherits it).ignoreLocal→ writes to<git-common-dir>/info/exclude(local-only, no tracked diff, shared across worktrees). Wired in a follow-up.Wired the tracked tier into
config initandsetupthrough a sharedreportEnsureIgnoredseam that prints a one-lineAdded .codemap/ to .gitignorenotice.Testing (TDD)
Tests written first, red → green.
go test ./...fully green,go vetclean.TestEnsureCodemapIgnored— tracked write, no-op-when-ignored, create-when-missing, append-preserving-newline,ignoreLocal→info/exclude, non-git skip.TestReportEnsureIgnored— notice on first run, silent when already ignored, silent outside git.Also smoke-tested the built binary:
codemap config initin a fresh repo prints the notice,git check-ignoreconfirms the rule, and a second run stays idempotent.Follow-ups (not in this PR)
ignoreLocalsafety-net into the lazy.codemap/creation paths (cmd/hooks.go,watch/daemon.go) — needs the helper promoted to a shared package sincewatchcan't callcmd's unexported helper.🤖 Generated with Claude Code