fix: bd sync works when on sync branch (GH#519)
When sync.branch is set to the current branch (e.g., main), bd sync now commits directly instead of failing with a worktree error. Changes: - sync.go: Detect when current branch == sync branch and skip worktree - sync.go: Show appropriate messages for direct-mode commits/pulls - doctor.go: Change from Error to OK status when on sync branch The fix allows users to work directly on the sync branch without having to switch to a different branch for bd sync to work. Closes: GH#519 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2498,16 +2498,14 @@ func checkSyncBranchConfig(path string) doctorCheck {
|
||||
currentBranch = strings.TrimSpace(string(output))
|
||||
}
|
||||
|
||||
// CRITICAL: Check if we're on the sync branch - this is a misconfiguration
|
||||
// that will cause bd sync to fail trying to create a worktree for a branch
|
||||
// that's already checked out
|
||||
// GH#519: Check if we're on the sync branch - this is supported but worth noting
|
||||
// bd sync will commit directly instead of using worktree when on sync branch
|
||||
if syncBranch != "" && currentBranch == syncBranch {
|
||||
return doctorCheck{
|
||||
Name: "Sync Branch Config",
|
||||
Status: statusError,
|
||||
Message: fmt.Sprintf("On sync branch '%s'", syncBranch),
|
||||
Detail: fmt.Sprintf("Currently on branch '%s' which is configured as the sync branch. bd sync cannot create a worktree for a branch that's already checked out.", syncBranch),
|
||||
Fix: "Switch to your main working branch: git checkout main",
|
||||
Status: statusOK,
|
||||
Message: fmt.Sprintf("On sync branch '%s' (direct mode)", syncBranch),
|
||||
Detail: fmt.Sprintf("Currently on sync branch '%s'. bd sync will commit directly instead of using worktree.", syncBranch),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user