Skip to content

feat(repos): add devops repos worktrees add that refuses a held issue - #2348

Merged
dan-petty merged 5 commits into
mainfrom
feat/2337-worktrees-add
Oct 27, 2026
Merged

dan-petty merged 5 commits into
mainfrom
feat/2337-worktrees-add

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops repos worktrees add <issue> --type <type> --slug <slug> creates the worktree of an issue in one place and one branch form, and refuses an issue that another agent already holds.

  • It fetches origin/main and creates .data/agent/worktrees/w-<issue> on the branch <type>/<issue>-<slug> at that tip. The branch has no upstream, so a plain git push cannot aim at main.
  • It refuses an issue when a worktree has a branch for it (any type and slug), when the directory w-<issue> exists, or when origin has a branch for it. The error names the holder. A local branch with no worktree holds nothing, because prune leaves such a branch after a merge.
  • A bad --type or --slug is a usage error (exit 2) before any git command runs. A missing origin is named.
  • --dry-run reads the local worktrees only, lists the three git commands and reads nothing from origin.
  • devops repos worktrees status shows the issue of each worktree (a column Issue and the JSON field issue).
  • The branch form lives in config/constants.py. tests/test_branch_form.py fails when it disagrees with the branch-name pre-commit hook or with the types of release-please-config.json.
  • CONTRIBUTING.md, SDLC.md and ROUTINE_TASKS.md name the command where they told readers to run git checkout -b.

The change reads git only. It drops the third source that the issue lists, an open pull request that closes the issue: GitHub's REST API has no closing-reference field, and the GraphQL field closedByPullRequestsReferences lists the open release pull request #2329 as closing #2336, which would hold every issue in the release notes. A pull request of this repository always has a pushed head branch, and the check on origin sees it. The design of the archived change records this.

Closes #2337

Plans #2337: a command that creates the worktree of an issue and refuses an issue that a worktree or a pushed branch holds.
The command creates the worktree w-<issue> on <type>/<issue>-<slug> at the fetched origin/main, with no upstream. It refuses an issue that a worktree, the standard directory or a branch of origin already holds, and its dry run reads no request from origin. Part of #2337.
…s status

The status table has an Issue column and the JSON has the field issue, read from a branch of the form <type>/<issue>-<slug>. The docs that start a branch name the new command. Part of #2337.
tests/test_agents_md_claims.py keeps the form in the naming table once. Part of #2337.
Archives 2337-worktrees-add and adds the capability repos-worktrees-add to the specs. Closes #2337.
@dan-petty

Copy link
Copy Markdown
Owner Author

Test evidence for this pull request.

  • Full gate: uv run devops ci --check --no-cache passes every check (exit 0) on the rebased branch, after #2345. An earlier run failed on the new authlib advisory GHSA-6v38-4h7w-rj9h and on tests/test_agents_md_claims.py. The advisory was fixed on main by another pull request. The test counts the branch form once in the naming section of CONTRIBUTING.md, and the last commit before the archive fixes my wording.
  • Red before green: tests/test_branch_form.py failed on the missing constants. tests/test_repos_worktrees_add.py failed 25 of 26 before the command existed. The new status tests failed with KeyError: 'issue'.
  • Real repository and real origin (this branch's code, --repo-dir /workspaces/devops-cli):
    • add 2341 --type fix --slug probe exited 1 and named the worktree w-2341 and its branch fix/2341-worktrees-prune-merged-pr.
    • add 9999 --type chore --slug probe --dry-run listed ls-remote, fetch and worktree add and created nothing.
    • add 9999 --type chore --slug probe created w-9999 at the tip of origin/main (518db63) with no upstream. A second add 9999 was refused and named w-9999. I removed the probe worktree and its branch afterwards.
    • worktrees status --json showed the issue of each worktree: 772, 2337, 2341, 2344 and 9999.
  • MCP: tests/test_mcp.py failed until add joined prune and status in the exclusion list of commands that manage local checkouts.

@dan-petty
dan-petty marked this pull request as ready for review October 27, 2026 15:38
@dan-petty
dan-petty merged commit a3b164d into main Oct 27, 2026
16 checks passed
@dan-petty
dan-petty deleted the feat/2337-worktrees-add branch October 27, 2026 16:18
dan-petty pushed a commit that referenced this pull request Oct 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.7.0](v0.6.5...v0.7.0)
(2026-10-27)


### Features

* **ci:** limit how many CPU-heavy gates run at once on one host
([#2339](#2339))
([115d1c1](115d1c1)),
closes [#2336](#2336)
* **ci:** make devops ci wait for a gate slot before a CPU-heavy check
([#2343](#2343))
([518db63](518db63)),
closes [#2336](#2336)
* **devcontainer:** onboard Kilo Code with a kilo.jsonc that exposes the
devops-cli MCP server
([#2332](#2332))
([3a6189e](3a6189e))
* **openspec:** commit the OpenSpec skills for Kilo Code
([#2334](#2334))
([9b4a824](9b4a824)),
closes [#2333](#2333)
* **repos:** add devops repos worktrees add that refuses a held issue
([#2348](#2348))
([a3b164d](a3b164d)),
closes [#2337](#2337)


### Bug Fixes

* **deps:** upgrade dnspython to fix GHSA-45c3-73f7-pv4m
([#2350](#2350))
([f50459d](f50459d))
* **k8s:** k8s apply renders the preview under --dry-run and starts no
child process
([#2328](#2328))
([16e26b0](16e26b0)),
closes [#2312](#2312)
* **k8s:** name the keyring entry when the Grafana admin password is
missing ([#2335](#2335))
([f9dcc79](f9dcc79))
* **repos:** worktrees prune removes only worktrees of merged pull
requests ([#2342](#2342))
([23d864d](23d864d)),
closes [#2341](#2341)
* **scan:** keep scan progress off stdout when the output format is json
([#2331](#2331))
([1b17048](1b17048)),
closes [#2216](#2216)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.

feat(repos): add devops repos worktrees add that refuses an issue another agent already holds

1 participant