fix(sync): avoid double export when uncommitted JSONL detected (bd-uuo9)
Add alreadyExported flag to skip redundant export. When gitHasUncommittedBeadsChanges() detects uncommitted changes, we export at line 175. The flag prevents the normal flow from exporting again at line 293. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -166,6 +166,8 @@ Use --merge to merge the sync branch back to main branch.`,
|
||||
// GH#885: Preflight check for uncommitted JSONL changes
|
||||
// This detects when a previous sync exported but failed before commit,
|
||||
// leaving the JSONL in an inconsistent state across worktrees.
|
||||
// Track if we already exported during pre-flight to avoid redundant export later.
|
||||
alreadyExported := false
|
||||
if hasUncommitted, err := gitHasUncommittedBeadsChanges(ctx); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to check for uncommitted changes: %v\n", err)
|
||||
} else if hasUncommitted {
|
||||
@@ -176,6 +178,7 @@ Use --merge to merge the sync branch back to main branch.`,
|
||||
FatalError("re-exporting to reconcile state: %v", err)
|
||||
}
|
||||
fmt.Println("✓ State reconciled")
|
||||
alreadyExported = true
|
||||
}
|
||||
|
||||
// GH#638: Check sync.branch BEFORE upstream check
|
||||
@@ -287,7 +290,7 @@ Use --merge to merge the sync branch back to main branch.`,
|
||||
}
|
||||
}
|
||||
|
||||
if !skipExport {
|
||||
if !skipExport && !alreadyExported {
|
||||
// Pre-export integrity checks
|
||||
if err := ensureStoreActive(); err == nil && store != nil {
|
||||
if err := validatePreExport(ctx, store, jsonlPath); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user