Skip to content

fix(claude-sync): commit what it adds instead of relying on chezmoi autoCommit - #529

Merged
Data-Wise merged 2 commits into
devfrom
feature/claude-sync-commit
Sep 23, 2026
Merged

Data-Wise merged 2 commits into
devfrom
feature/claude-sync-commit

Conversation

@Data-Wise

Copy link
Copy Markdown
Owner

Summary

claude-sync assumed chezmoi commits automatically, but that only happens when chezmoi's git.autoCommit is configured, and it isn't on this machine. So chezmoi add and re-add only put files into the chezmoi source repo. The ahead-of-origin/main check then found no new commit, and claude-sync printed nothing to push (already synced) while changes built up uncommitted. The dotfiles repo had collected 50 uncommitted changes before a manual commit (Data-Wise/dotfiles fc776f6).

  • New _claude_sync_commit adds and commits only the ~/.claude part of the source repo (chezmoi source-path ~/.claude). Other dotfile changes that are staged stay staged.
  • A plain run and --no-push now commit. --add now commits before pushing (before, it pushed without committing).
  • The file header now names flow-cli as the source. It wrongly said the file was managed by chezmoi, but ~/.config/zsh links to flow-cli/zsh.

Tests

New tests/test-claude-sync.zsh, registered in run-all.sh. It replaces chezmoi with a shell function that copies files into a throwaway source repo whose remote is a local bare repo, so real git commit and git push run without touching real dotfiles.

Before the fix, 4 of 6 failed. After it, 6 of 6 pass:

✓ All tests passed: 6/6
Case What it proves
plain run new memory file reaches origin, source repo left clean, prints "pushed"
--no-push 1 local commit, origin unchanged
second run with no changes no new commit, prints "nothing to push"
unrelated staged dotfile not included in the commit, still staged afterward
--add the new path is committed, then pushed

Full suite ./tests/run-all.sh: 86 passed, 3 failed, 0 timeout, 0 skipped. The 3 failures (test-doctor, e2e-em-dispatcher, test-atlas-contract) also fail with this change set aside via git stash -u, so they're caused by this machine's setup and not by this PR.

Not in this PR

Test runs leave memory folders for their temporary directories (~/.claude/projects/-private-var-folders-*flow-test-sandbox-*). The default run adds every ~/.claude/projects/*/memory folder, so it will now commit those empty .keep files too. Filtering them out is a separate change.

🤖 Generated with Claude Code

Data-Wise and others added 2 commits September 23, 2026 11:32
…utoCommit

chezmoi commits by itself only when git.autoCommit is configured. Without it,
chezmoi add/re-add only staged into the source dir, the local-ahead check saw
no commit, and claude-sync printed 'nothing to push (already synced)' while
changes piled up uncommitted (50 on this machine before a manual commit).

- _claude_sync_commit stages and commits only the ~/.claude source subtree,
  so unrelated staged dotfile edits stay staged.
- Default and --no-push now commit; --add commits before pushing.
- Header now names flow-cli as the source (it said chezmoi-managed).
- New tests/test-claude-sync.zsh (6 cases; fake chezmoi + real git against a
  throwaway bare origin), registered in run-all.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A --add of a path outside ~/.claude was staged by chezmoi but never
committed, then the push reported success with nothing new. The commit
helper now takes the target whose source path it commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Data-Wise
Data-Wise merged commit 09b4876 into dev Sep 23, 2026
3 checks passed
Data-Wise added a commit that referenced this pull request Sep 23, 2026
* fix(claude-sync): skip memory dirs of $TMPDIR-rooted projects

Test sandboxes and throwaway sessions under /private/var/folders leave
~/.claude/projects/-private-var-folders-*/memory dirs. Now that claude-sync
commits (#529), those empty .keep dirs would land in dotfiles. 10 such dirs
on this machine (68 memory dirs -> 58 synced).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(claude-sync): exclude $TMPDIR copies already in the source at commit

Skipping -private-var-folders-* memory dirs at chezmoi-add time does not stop
copies an earlier run already put in the source dir: the commit step's
'git add -A -- dot_claude' would still pick them up. Exclude them in the
pathspec too. Dry run against the real dotfiles source: 5 such .keep files
staged without the exclude, 0 with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@Data-Wise
Data-Wise deleted the feature/claude-sync-commit branch September 23, 2026 18:05
Data-Wise added a commit that referenced this pull request Sep 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant