Add main_branch config key for branch protection and base branch selection#10
Merged
Add main_branch config key for branch protection and base branch selection#10
Conversation
…ction Introduces a main_branch field in .worktree.yml that serves as the single source of truth for the repository's primary branch. This solves three problems: wt remove now refuses to delete the main branch worktree, wt add creates new branches from the configured main branch instead of HEAD, and wt prune uses the config value instead of runtime detection. The main branch is auto-detected at clone/init time and written to config. Existing projects without main_branch default to "main" for backward compatibility.
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.
Summary
main_branchfield to.worktree.ymlconfig (defaults tomain, auto-detected at clone/init time)wt removenow refuses to delete the main branch worktree (hard guard, no --force override)wt addcreates new branches from the configured main branch instead of implicit HEADwt pruneuses the config value instead of runtimeGetDefaultBranch()detectionResolveStartPoint()helper that triesorigin/<branch>, local<branch>, thenHEADfor robust ref resolution in bare reposTest plan
make devpasses (fmt, vet, all tests including e2e)wt clone <repo>writesmain_branch: <detected>to.worktree.ymlwt initin an existing repo detects and writes the default branchwt add feature/testcreates a new branch from the configured main branchwt remove mainis rejected with an error messagewt prunestill protects the main branch from removalmain_branchin config default tomain(backward compat)