Repository navigation
feat(scripts): create worktrees with new-worktree.sh - #333
Merged
Merged
Conversation
scripts/new-worktree.sh <name> [<branch>] fetches origin, fast-forwards local main where that is safe and refuses when main holds commits origin/main lacks, creates ../span-<name> on a branch that tracks no remote so a bare push can never land on main, links .env from the primary checkout, and runs the new worktree's setup-hooks.sh. From beside the primary checkout, ../../span/span-panel-api still resolves to the library, so no bridge is needed. The worktree gets a virtual environment of its own: editable installs record one checkout's source path, so a shared environment imports whichever checkout synced last. When a library worktree of the same name exists, the script prints the three-distribution `uv pip install -e` command rather than running it, because the next `uv sync` silently undoes that override. Main is moved with update-ref rather than `branch --force`, which would also rewrite its upstream, and a checked-out main is fast-forwarded only when it has no uncommitted tracked changes.
AGENTS.md gains a Worktrees section: create worktrees with scripts/new-worktree.sh rather than `git worktree add` or a built-in worktree tool, never share a virtual environment between checkouts, and install a library worktree explicitly when testing against it. The script joins the permitted operations. CLAUDE.md imports AGENTS.md. Claude Code reads CLAUDE.md and not AGENTS.md, so until now none of these instructions reached it, including the translation workflow, where documentation artifacts belong, and the service registration requirements.
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.
Worktrees of this repository have been created with
scripts/new-worktree.shfrom a branch that never reachedmainor a pre-release branch. This brings the script and its instructions in.Change
scripts/new-worktree.sh <name> [<branch>]:origin, fast-forwards localmainwhere that is safe, and refuses whenmainholds commitsorigin/mainlacks.mainis moved withupdate-refrather thanbranch --force, which would also rewrite its upstream, and a checked-outmainis fast-forwarded only when it has no uncommitted tracked changes.../span-<name>on a branch that tracks no remote, so a baregit pushcan never land onmain, links.envfrom the primary checkout, and runs the worktree'ssetup-hooks.sh.../../span/span-panel-apistill resolves to the library, so no bridge is needed.uv pip install -ecommand rather than running it, because the nextuv syncsilently undoes that override.developer.md: a Worktrees section.AGENTS.md: a Worktrees section, and the script among the permitted operations.CLAUDE.md: importsAGENTS.md, for agents that read onlyCLAUDE.md.Checks
shellcheckis clean. All hooks pass over the branch: 2470 passed, 1 skipped, against the published span-panel-api 3.8.0b1, schema-0 1.3.0b1 and schema-1 1.4.0b2 this branch pins.Not covered
origin/main. Work for a pre-release branch, this one included, is reset onto it by hand after the script runs.setup-hooks.shinstalls it from whichever checkout runs first, and the hook records the path of theprekthat installed it. If that was a worktree's environment, the hook breaks once the worktree is removed. The library's companion change guards against this for pre-commit (feat(scripts): create worktrees with new-worktree.sh and keep the shared hook bound to the primary checkout span-panel-api#218). The hook here currently runs a systemprek.