[PR #13495] fix(snapshot): respect info exclude in snapshot staging #14688

Open
opened 2026-02-16 18:19:27 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13495

State: open
Merged: No


What does this PR do?

fixes #13474

What I changed:

  • In packages/opencode/src/snapshot/index.ts, I replaced direct git add . calls in track, patch, and diff with a shared add() helper.
  • Before staging, add() now copies the project’s .git/info/exclude into the snapshot repo’s info/exclude (syncExclude()).
  • If the project exclude file is missing/unresolvable, it writes an empty snapshot info/exclude so stale patterns are not retained.
    Why this works:
  • Snapshot git operations now run with the same per-repo exclude patterns as the real project repo.
  • It preserves normal git behavior for global excludes (we are no longer overriding core.excludesFile per command), so both repo-local and global ignores are respected.

How did you verify your code works?

  • Added regression tests in packages/opencode/test/snapshot/snapshot.test.ts:
    • git info exclude changes (ensures .git/info/exclude entries are ignored by snapshot patch/diff)
    • git info exclude keeps global excludes (ensures global excludes still apply alongside repo info/exclude)
  • Ran:
    • bun test ./test/snapshot/snapshot.test.ts (from packages/opencode)
  • Result:
    • 43 pass, 1 skip, 0 fail
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13495 **State:** open **Merged:** No --- ### What does this PR do? fixes #13474 What I changed: - In packages/opencode/src/snapshot/index.ts, I replaced direct git add . calls in track, patch, and diff with a shared add() helper. - Before staging, add() now copies the project’s .git/info/exclude into the snapshot repo’s info/exclude (syncExclude()). - If the project exclude file is missing/unresolvable, it writes an empty snapshot info/exclude so stale patterns are not retained. Why this works: - Snapshot git operations now run with the same per-repo exclude patterns as the real project repo. - It preserves normal git behavior for global excludes (we are no longer overriding core.excludesFile per command), so both repo-local and global ignores are respected. --- How did you verify your code works? - Added regression tests in packages/opencode/test/snapshot/snapshot.test.ts: - git info exclude changes (ensures .git/info/exclude entries are ignored by snapshot patch/diff) - git info exclude keeps global excludes (ensures global excludes still apply alongside repo info/exclude) - Ran: - bun test ./test/snapshot/snapshot.test.ts (from packages/opencode) - Result: - 43 pass, 1 skip, 0 fail
yindo added the pull-request label 2026-02-16 18:19:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14688