fix(daemon): add sync-branch guard to daemon code paths (#1271)

* fix(daemon): skip export when sync-branch matches current

Prevent redundant export operations by checking if the daemon's sync
branch matches the current active branch.

Previously, the daemon would attempt to perform an export even when
already on the target branch. This logic now skips the export step in
such cases to avoid unnecessary overhead and potential conflicts.
Includes a new integration test to verify the guard logic.

* fix(daemon): prevent sync on guarded branches

Add checks to verify if a branch is guarded before performing automated
sync cycles, auto-imports, or branch-specific commit and pull operations.
This prevents the daemon from modifying protected branches or running
synchronization tasks where they are restricted.

Includes comprehensive integration tests to verify the guard logic
during sync-branch operations.

* fix(daemon): warn on sync branch misconfiguration at startup

The daemon now checks for sync branch name conflicts during its startup
loop. This provides early feedback if the sync branch is configured
in a way that might conflict with existing branches or other settings.

The warnIfSyncBranchMisconfigured function performs the validation
and logs a warning to the console. Integration tests verify that
the daemon correctly identifies and reports these misconfigurations
at initialization.
This commit is contained in:
Peter Chanthamynavong
2026-01-24 17:10:08 -08:00
committed by GitHub
parent b7d650bd8e
commit dbd505656d
4 changed files with 1162 additions and 2 deletions

View File

@@ -31,7 +31,12 @@ func syncBranchCommitAndPushWithOptions(ctx context.Context, store storage.Stora
if !hasGitRemote(ctx) {
return true, nil // Skip sync branch commit/push in local-only mode
}
// Guard: Skip if sync-branch == current-branch (GH#1258)
if shouldSkipDueToSameBranch(ctx, store, "sync-branch commit", log) {
return false, nil
}
// Get sync branch configuration (supports BEADS_SYNC_BRANCH override)
syncBranch, err := syncbranch.Get(ctx, store)
if err != nil {
@@ -252,7 +257,12 @@ func syncBranchPull(ctx context.Context, store storage.Storage, log daemonLogger
if !hasGitRemote(ctx) {
return true, nil // Skip sync branch pull in local-only mode
}
// Guard: Skip if sync-branch == current-branch (GH#1258)
if shouldSkipDueToSameBranch(ctx, store, "sync-branch pull", log) {
return false, nil
}
// Get sync branch configuration (supports BEADS_SYNC_BRANCH override)
syncBranch, err := syncbranch.Get(ctx, store)
if err != nil {