fix(worktree): Base new worktrees on fresh main#2047
Merged
Conversation
Fetch origin/main before creating a new main-based branch so stale local refs cannot seed new worktrees. Preserve existing-branch behavior and abort cleanly when the fetch fails. Refs SMI-5823 Co-Authored-By: Codex <noreply@openai.com>
E2E Test ResultsE2E Test Results - July 25, 2026Summary
Test Results
Generated by skillsmith E2E test suite |
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.
Business Summary
What shipped: New worktrees based on
mainnow start from the latest remote commit, even when the developer's localmaincheckout is stale.What shipped: Existing branches retain their current behavior, while an unavailable remote stops new-branch creation before a stale branch or partial worktree can be created.
Quality bar: Three real-Git fixtures cover fresh remote base selection, unchanged local
main, existing-branch bypass, and fail-before-create behavior. The full pre-push suite, lint, formatting, TypeScript, Bash syntax, standards audit, and 17 focused create-worktree tests pass.Net result: SMI-5823 Phase 3 is independently complete. Only the reviewed container-sprawl visibility work remains as Phase 4.
Technical detail
add_worktree_git_entryto isolate the branch-cut decision.main, runsgit fetch --no-recurse-submodules origin mainand passesorigin/maindirectly togit worktree add.mainref.git worktree add, leaving no new branch or directory.Verification
npx vitest run scripts/tests/create-worktree-base.test.ts scripts/tests/create-worktree-ready-probe.test.ts— 17/17 passednpm run lint— passednpm run format:check— passednpm run typecheck— passednpm run audit:standards— passed with existing warningsbash -n scripts/create-worktree.sh— passedshellcheck— no new findings; four existing informational/style exclusions remainnpm run preflightreaches the existing dependency-scanner baseline and stops on@isaacs/keytar, Node'sasync_hooks, and runtime-provided@wdio/globals; this is unchanged fromorigin/mainand prior SMI-5823 phases.Refs SMI-5823.