Skip to content

fix(#343): auto-detect default branch instead of hardcoding origin/main - #345

Merged
admarble merged 2 commits into
mainfrom
feature/343-bug-run-worktree-creation-and-rebase-hardcode-
Mar 11, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/343-bug-run-worktree-creation-and-rebase-hardcode-

Conversation

@admarble

@admarble admarble commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add detectDefaultBranch() utility that reads origin/HEAD symbolic ref (no network), falls back to git remote set-head origin --auto, then to "main"
  • Wire into resolution chain: --base flag → settings.run.defaultBase → auto-detect → "main"
  • Update rebaseBeforePR(), checkWorktreeFreshness(), ensureWorktree(), and pr-status.ts helpers to accept a baseBranch parameter instead of hardcoding "origin/main"
  • Pass resolved base branch through all call sites (runCommand, runIssueWithLogging, executeBatch)

Test plan

  • 4 new unit tests for detectDefaultBranch() (symbolic-ref, fallback, final default)
  • New test verifying rebaseBeforePR() uses custom base branch ("master") in fetch and rebase commands
  • All 100 tests pass
  • TypeScript build passes with no errors
  • No remaining hardcoded "origin/main" in code paths (only in comments updated to say "base branch")

Fixes #343

🤖 Generated with Claude Code

admarble added 2 commits March 8, 2026 19:41
Add detectDefaultBranch() that reads origin/HEAD symbolic ref, falls
back to `git remote set-head origin --auto`, then to "main". Wire it
into the resolution chain so --base flag, settings.run.defaultBase,
and auto-detection all work. Update rebaseBeforePR(),
checkWorktreeFreshness(), and pr-status helpers to accept a baseBranch
parameter instead of hardcoding "origin/main".

Fixes #343
Replace hardcoded "main" in user-facing stale worktree warnings
with the resolved detectedBase variable.
@admarble
admarble merged commit d6d504a into main Mar 11, 2026
5 of 6 checks passed
@admarble
admarble deleted the feature/343-bug-run-worktree-creation-and-rebase-hardcode- branch March 11, 2026 14:05
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.

bug(run): worktree creation and rebase hardcode 'origin/main' — fails on repos with non-main default branch

1 participant