Skip to content

fix: add all sidecar state files to .gitignore on init and startup#211

Merged
marcus merged 1 commit intomainfrom
fix/gitignore-sidecar-entries
Feb 27, 2026
Merged

fix: add all sidecar state files to .gitignore on init and startup#211
marcus merged 1 commit intomainfrom
fix/gitignore-sidecar-entries

Conversation

@marcus
Copy link
Owner

@marcus marcus commented Feb 27, 2026

Problem

When sidecar ran for the first time against an existing repo, the .gitignore was never updated. For new repos (via git init in sidecar), only .todos/ was added. This meant sidecar state files appeared as untracked files before the first worktree was created.

Fixes #201

Solution

Option 1 from the issue: add all sidecar entries unconditionally.

Changes

  • sidecarGitignoreEntries — renamed from initRepoGitignoreEntries and expanded to cover all sidecar state paths:
    .todos/
    .sidecar/
    .sidecar-agent
    .sidecar-task
    .sidecar-pr
    .sidecar-start.sh
    .sidecar-base
    .td-root
    
  • Start() in gitstatus plugin — calls ensureGitignoreEntries for existing repos on every startup. The call is idempotent (only appends missing entries) and best-effort (errors are non-fatal).
  • Tests — new TestEnsureGitignoreEntries_AllSidecarEntries validates the full entry list; TestStart_EnsuresGitignoreForExistingRepo validates the existing-repo path.

Testing

go build ./cmd/sidecar/
go test ./...

All pass.

Previously, only '.todos/' was added to .gitignore when initializing a
new git repository, and nothing was added for existing repos. This meant
sidecar state files (.sidecar/, .sidecar-agent, .sidecar-task, etc.)
could appear as untracked files before the first worktree was created.

Changes:
- Rename initRepoGitignoreEntries to sidecarGitignoreEntries and expand
  it to include all sidecar state paths (.sidecar/, .sidecar-agent,
  .sidecar-task, .sidecar-pr, .sidecar-start.sh, .sidecar-base, .td-root)
- Call ensureGitignoreEntries in Start() for existing repos so entries
  are added on every sidecar startup (idempotent, best-effort)
- Add tests: AllSidecarEntries validates the full list; Start_EnsuresGitignore
  validates the existing-repo path

Fixes #201
@marcus marcus merged commit b591ba5 into main Feb 27, 2026
0 of 2 checks passed
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.

Updated .gitignore by sidecar seems to be incomplete

1 participant