Skip to content

feat: scripts/worktree.sh creates a ready worktree with one command - #389

Merged
yw0nam merged 5 commits into
mainfrom
feat/worktree-script
Oct 21, 2026
Merged

yw0nam merged 5 commits into
mainfrom
feat/worktree-script

Conversation

@yw0nam

@yw0nam yw0nam commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Summary

scripts/worktree.sh <branch> creates a ready worktree in one command: it fetches origin, adds <primary>.wt/<branch with / as -> on a new branch from origin/main with no upstream, and links the primary checkout's gitignored .env so integration tests in the worktree reach the configured endpoints. It works from the primary checkout and from inside any worktree of it.

scripts/worktree.sh feat/x
  git rev-parse --git-common-dir      → primary checkout (fails fast outside a repository)
  git fetch -q origin
  git worktree add --no-track -b feat/x <primary>.wt/feat-x origin/main
  ln -s <primary>/.env <primary>.wt/feat-x/.env   (only when the primary has one and the worktree has none)
  → prints <primary>.wt/feat-x

Review notes (two-axis review, a fix round, a final two-axis review):

  • Applied: no upstream on the new branch (a stray git push cannot target main), link .env only when missing, a test for running from inside a worktree, test env stripped of inherited GIT_*, fail fast at rev-parse.
  • Not changed: the primary comes from the caller's directory, not the script's location; resolving it from the script would make the tests create worktrees in the real repository. feat/a and feat-a map to one path and git refuses the second. The "worktree already has .env" branch has no test: .env is gitignored here, so a fresh worktree never has one.

Related issues

None.

Runtime evidence (required for ingest / retrieval / serving behavior)

Run for real in this repository, then both throwaway worktrees and branches removed:

$ scripts/worktree.sh evidence/worktree-script            (from the primary checkout)
…/memory_base.wt/evidence-worktree-script
branch: evidence/worktree-script
HEAD == origin/main
fatal: no upstream configured for branch 'evidence/worktree-script'
.env is a symlink -> …/memory_base/.env
git status --ignored: !! .env

$ scripts/worktree.sh evidence/worktree-script-2          (from inside a worktree)
…/memory_base.wt/evidence-worktree-script-2

$ (cd /tmp && bash …/scripts/worktree.sh feat/x)
fatal: not a git repository (or any of the parent directories): .git   → exit 128, nothing created

Verification

  • uv run pytest passes — tests/test_worktree_script.py 3 passed
  • uv run ruff format --check . and uv run ruff check . pass
  • docker compose build mcp passes (Dockerfile / dependency changes) — N/A
  • Runtime evidence attached above, or N/A justified

Checklist (core principles)

  • Selective storage — notes stay distilled; verbatim text lives only in doc_rows and the turns lane
  • Source-specific logic stays out of the source-agnostic core (ingest pipeline, retrieval, serving)
  • No hardcoded endpoints/models — configuration lives in .env
  • New/changed behavior ships a test in this PR (or skip-tests label justified)

@yw0nam
yw0nam merged commit a8d9443 into main Oct 21, 2026
4 checks passed
@yw0nam
yw0nam deleted the feat/worktree-script branch October 21, 2026 06:12
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