fix: honor declared branch_strategy over clone origin/HEAD in create#54
Merged
Conversation
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found via dogfood.
bough createchose each worktree's base viaDetectBase(repoSrc, branch_strategy), which returnsorigin/HEADfirst and usesbranch_strategyonly as a fallback. Agit clone --localrecordsorigin/HEADas 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: developgotauba-dbmigration's worktree based onfeature/issue-1394-…(the source was on that branch at--localclone time) while a sibling sub-repo ondevelopwas 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_strategyis now authoritative;origin/HEADauto-detection is used only whenbranch_strategyis empty (chooseBaseininternal/cli/create.go). Table-driven regression test added. Verified live: a re-create now cuts the sub-repo fromdevelop, and with fetch enabled the full create → engines → .env.local → migrate path commits green.