Skip to content

fix(worktree): Base new worktrees on fresh main#2047

Merged
wrsmith108 merged 1 commit into
mainfrom
fix/smi-5823-create-worktree
Jul 25, 2026
Merged

fix(worktree): Base new worktrees on fresh main#2047
wrsmith108 merged 1 commit into
mainfrom
fix/smi-5823-create-worktree

Conversation

@wrsmith108

Copy link
Copy Markdown
Member

Business Summary

What shipped: New worktrees based on main now start from the latest remote commit, even when the developer's local main checkout 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

  • Adds add_worktree_git_entry to isolate the branch-cut decision.
  • For a new branch whose base is main, runs git fetch --no-recurse-submodules origin main and passes origin/main directly to git worktree add.
  • Does not reset or otherwise update the developer's local main ref.
  • Existing branches never fetch or consult the requested base.
  • A failed fetch exits before 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 passed
  • npm run lint — passed
  • npm run format:check — passed
  • npm run typecheck — passed
  • npm run audit:standards — passed with existing warnings
  • bash -n scripts/create-worktree.sh — passed
  • shellcheck — no new findings; four existing informational/style exclusions remain
  • Full guarded pre-push test and security suites — passed
  • npm run preflight reaches the existing dependency-scanner baseline and stops on @isaacs/keytar, Node's async_hooks, and runtime-provided @wdio/globals; this is unchanged from origin/main and prior SMI-5823 phases.

Refs SMI-5823.

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>
@github-actions

Copy link
Copy Markdown

E2E Test Results

E2E Test Results - July 25, 2026

Summary

  • Status: ✅ PASSED
  • Total Duration: 0.00s
  • Generated: 2026-07-25T15:34:42.844Z

Test Results

Phase Status Duration
CLI E2E ⏭️ Skipped -
MCP E2E ⏭️ Skipped -

Generated by skillsmith E2E test suite

@wrsmith108
wrsmith108 merged commit 1dbfa63 into main Jul 25, 2026
35 checks passed
@wrsmith108
wrsmith108 deleted the fix/smi-5823-create-worktree branch July 25, 2026 15:47
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