Skip to content

fix: honor declared branch_strategy over clone origin/HEAD in create#54

Merged
ikeikeikeike merged 1 commit into
mainfrom
fix/create-honor-branch-strategy
Jun 28, 2026
Merged

fix: honor declared branch_strategy over clone origin/HEAD in create#54
ikeikeikeike merged 1 commit into
mainfrom
fix/create-honor-branch-strategy

Conversation

@ikeikeikeike

Copy link
Copy Markdown
Member

Found via dogfood. bough create chose each worktree's base via DetectBase(repoSrc, branch_strategy), which returns origin/HEAD first and uses branch_strategy only as a fallback. A git clone --local records origin/HEAD as whatever the source had checked out — so a clone made while the source sat on a feature branch cut the worktree off that feature branch instead of the declared base.

Concretely: a monorepo declaring branch_strategy: develop got auba-dbmigration's worktree based on feature/issue-1394-… (the source was on that branch at --local clone time) while a sibling sub-repo on develop was unaffected — exposing the inconsistency. The wrong base then cascaded into a post_create migrate failure (the feature-branch Makefile predated the merged DB-port fix, so mysqldef hit the default-port main DB).

Fix: the explicit, required branch_strategy is now authoritative; origin/HEAD auto-detection is used only when branch_strategy is empty (chooseBase in internal/cli/create.go). Table-driven regression test added. Verified live: a re-create now cuts the sub-repo from develop, and with fetch enabled the full create → engines → .env.local → migrate path commits green.

bough create chose each worktree's base via DetectBase(repoSrc, branch_strategy),
which returns origin/HEAD first and uses branch_strategy only as a fallback.
A `git clone --local` records origin/HEAD as whatever the source had checked
out, so a clone made while the source sat on a feature branch cut the new
worktree off that feature branch instead of the declared base.

Found via dogfood: a monorepo declaring `branch_strategy: develop` got one
sub-repo (auba-dbmigration) based on `feature/issue-1394-video-archive-table`
because the source was on that branch at `--local` clone time, while a sibling
sub-repo on develop was unaffected. The wrong base then cascaded into a
post_create migrate failure (the feature-branch Makefile predated the merged
DB-port fix, so mysqldef hit the default-port main DB instead of the engine).

The explicit, required branch_strategy is now authoritative; origin/HEAD
auto-detection is used only when branch_strategy is empty. Extracted
chooseBase() with a table-driven regression test.

Verified live against the dogfood monorepo: a re-create now cuts
auba-dbmigration from develop (was the feature branch), and with fetch enabled
(fresh origin/develop) the full create -> engines -> .env.local -> migrate
path commits green.
@ikeikeikeike
ikeikeikeike merged commit 6d42ec7 into main Jun 28, 2026
9 checks passed
@ikeikeikeike
ikeikeikeike deleted the fix/create-honor-branch-strategy branch June 28, 2026 12:40
ikeikeikeike added a commit that referenced this pull request Jun 29, 2026
fix: retrospective-review follow-ups for v0.9.18 (#48#54)
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.

1 participant