From f92090344a2115d7ea93d98b53ae2bb88150c517 Mon Sep 17 00:00:00 2001 From: beads/crew/dave Date: Sun, 4 Jan 2026 16:16:37 -0800 Subject: [PATCH] fix: finalize metadata after commit, not after push (GH#885) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In performExport, if git commit succeeded but push failed, the finalizeExportMetadata() was never called because we returned early. This meant metadata would not reflect the successful export+commit. Now finalize is called: - Right after syncBranchCommitAndPush succeeds - Right after gitCommit succeeds (before push attempt) - When no git changes exist (export still happened) Push failure still returns early, but metadata is already updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 Executed-By: beads/crew/dave Rig: beads Role: crew --- cmd/bd/daemon_sync.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/bd/daemon_sync.go b/cmd/bd/daemon_sync.go index 305f8463..ce9bbcae 100644 --- a/cmd/bd/daemon_sync.go +++ b/cmd/bd/daemon_sync.go @@ -474,8 +474,11 @@ func performExport(ctx context.Context, store storage.Storage, autoCommit, autoP return } - // If sync branch not configured, use regular commit - if !committed { + if committed { + // GH#885: Finalize after sync branch commit succeeded + finalizeExportMetadata() + } else { + // If sync branch not configured, use regular commit hasChanges, err := gitHasChanges(exportCtx, jsonlPath) if err != nil { log.log("Error checking git status: %v", err) @@ -490,6 +493,10 @@ func performExport(ctx context.Context, store storage.Storage, autoCommit, autoP } log.log("Committed changes") + // GH#885: Finalize after git commit succeeded, before push + // Push failure shouldn't prevent metadata update since commit succeeded + finalizeExportMetadata() + // Auto-push if enabled (GH#872: use sync.remote config) if autoPush { configuredRemote, _ := store.GetConfig(exportCtx, "sync.remote") @@ -499,11 +506,11 @@ func performExport(ctx context.Context, store storage.Storage, autoCommit, autoP } log.log("Pushed to remote") } + } else { + // No git changes but export happened - finalize metadata + finalizeExportMetadata() } } - - // GH#885: NOW finalize metadata after git commit succeeded - finalizeExportMetadata() } else if skipGit { // Git-free mode: finalize immediately since there's no git to wait for finalizeExportMetadata()