feat: complete isolated-worktree helpers — worktree-review, worktree-clean, tests (#39) #41

Closed
jcwalker3 wants to merge 0 commits from feat/issue-39-worktree-helpers into master
Owner

Closes #39. Follow-up to #38.

Context

#38 merged the isolated-worktree standard partiallybranches/ gitignore, runbook section, and scripts/worktree-start are on master (7e8256c). This PR adds the remaining acceptance items: the worktree-review and worktree-clean helpers + tests. (Issue #39 was originally filed as the same task, found to duplicate #38, then repurposed to track this remainder.)

What

  • scripts/worktree-review — isolated detached review worktree under branches/review-<branch> (fetch/prune first, refuse to overwrite, print path, --dry-run). Detached so a reviewer can't accidentally commit and review never blocks the author's folder.
  • scripts/worktree-clean — the only deleting helper: removes a branches/ worktree after merge/close, refuses a dirty worktree (no --force), optionally safe-deletes a merged branch (git branch -d), fetch/prune first, --dry-run. Deletes nothing unless explicitly invoked.
  • tests/test_worktrees.py — path generation + refuse-to-overwrite for all three helpers via --dry-run (no real worktrees/branches/network/deletions).
  • runbook — references worktree-review / worktree-clean + the --dry-run flag.

Behavior / safety

Helpers fetch/prune first, branch from remote master (start-ref default prgs/master for start, prgs/<branch> for review), refuse to overwrite an existing worktree, print the created path, and never delete unless cleanup is explicitly requested. No secrets. No change to MCP runtime, Gitea API ops, credential storage, or the profile model.

Checks

  • bash -n clean on all three scripts.
  • Full suite: 286 passed, 0 failures, 0 errors (main checkout with creds; JUnit XML — harness swallows pytest stdout on multi-file runs). 8 new worktree tests included.
  • git diff --check: clean.

Notes for reviewer

  • Done on a normal branch in the main checkout (not a branches/ worktree): the #38 worktree was removed by external cleanup mid-task; committing on a plain branch avoided losing work again. The standard itself is now in mainline for future use.
  • Pre-existing, unrelated: tests/test_mcp_server.py::TestEditPR::test_edit_pr_no_fields_raises fails only when run from a checkout without Gitea .env creds (it calls _auth before the no-fields ValueError). Passes in the main checkout. Worth a separate issue to reorder that validation — out of scope here.

Files changed

scripts/worktree-review (new), scripts/worktree-clean (new), tests/test_worktrees.py (new), docs/llm-workflow-runbooks.md.


⚠️ Authored by me — do not self-merge. Needs review by another author.

Closes #39. Follow-up to #38. ## Context #38 merged the isolated-worktree standard **partially** — `branches/` gitignore, runbook section, and `scripts/worktree-start` are on `master` (`7e8256c`). This PR adds the remaining acceptance items: the `worktree-review` and `worktree-clean` helpers + tests. (Issue #39 was originally filed as the same task, found to duplicate #38, then repurposed to track this remainder.) ## What - **`scripts/worktree-review`** — isolated **detached** review worktree under `branches/review-<branch>` (fetch/prune first, refuse to overwrite, print path, `--dry-run`). Detached so a reviewer can't accidentally commit and review never blocks the author's folder. - **`scripts/worktree-clean`** — the **only** deleting helper: removes a `branches/` worktree after merge/close, **refuses a dirty worktree** (no `--force`), optionally safe-deletes a merged branch (`git branch -d`), fetch/prune first, `--dry-run`. Deletes nothing unless explicitly invoked. - **`tests/test_worktrees.py`** — path generation + refuse-to-overwrite for all three helpers via `--dry-run` (no real worktrees/branches/network/deletions). - **runbook** — references `worktree-review` / `worktree-clean` + the `--dry-run` flag. ## Behavior / safety Helpers fetch/prune first, branch from remote `master` (start-ref default `prgs/master` for start, `prgs/<branch>` for review), refuse to overwrite an existing worktree, print the created path, and never delete unless cleanup is explicitly requested. No secrets. No change to MCP runtime, Gitea API ops, credential storage, or the profile model. ## Checks - `bash -n` clean on all three scripts. - Full suite: **286 passed, 0 failures, 0 errors** (main checkout with creds; JUnit XML — harness swallows pytest stdout on multi-file runs). 8 new worktree tests included. - `git diff --check`: clean. ## Notes for reviewer - Done on a normal branch in the main checkout (not a `branches/` worktree): the `#38` worktree was removed by external cleanup mid-task; committing on a plain branch avoided losing work again. The standard itself is now in mainline for future use. - Pre-existing, unrelated: `tests/test_mcp_server.py::TestEditPR::test_edit_pr_no_fields_raises` fails **only** when run from a checkout without Gitea `.env` creds (it calls `_auth` before the no-fields `ValueError`). Passes in the main checkout. Worth a separate issue to reorder that validation — out of scope here. ## Files changed `scripts/worktree-review` (new), `scripts/worktree-clean` (new), `tests/test_worktrees.py` (new), `docs/llm-workflow-runbooks.md`. --- ⚠️ Authored by me — do **not** self-merge. Needs review by another author.
jcwalker3 added 1 commit 2026-07-02 01:55:25 -05:00
Finishes the isolated-worktree standard begun in #38 (which merged the
branches/ gitignore, runbook, and scripts/worktree-start). Adds the two
remaining helpers and their tests.

- scripts/worktree-review: isolated DETACHED review worktree under
  branches/review-<branch> (fetch/prune first, refuse to overwrite, print path,
  --dry-run). Detached so a reviewer cannot accidentally commit and review work
  never blocks the author's implementation folder.
- scripts/worktree-clean: the only deleting helper — removes a branches/
  worktree after merge/close, refuses a dirty worktree (no --force), optionally
  safe-deletes a merged branch (git branch -d), fetch/prune first, --dry-run.
  Deletes nothing unless explicitly invoked.
- tests/test_worktrees.py: path generation + refuse-to-overwrite for all three
  helpers via --dry-run (no real worktrees/branches/network/deletions).
- runbook: reference worktree-review / worktree-clean and the --dry-run flag.

Checks: bash -n clean on all three scripts; git diff --check clean; full suite
286 passed, 0 failures.

Closes #39. Follow-up to #38.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jcwalker3 closed this pull request 2026-07-02 02:03:00 -05:00
jcwalker3 deleted branch feat/issue-39-worktree-helpers 2026-07-02 02:03:00 -05:00

Pull request closed

Sign in to join this conversation.