Skip to content

feat(repos): make devops repos worktrees add remove merged worktrees first - #2351

Merged
dan-petty merged 6 commits into
mainfrom
feat/2338-reclaim-merged-worktrees
Oct 27, 2026
Merged

dan-petty merged 6 commits into
mainfrom
feat/2338-reclaim-merged-worktrees

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops repos worktrees add now removes the worktrees of merged work first, so merged worktrees leave the disk without a person running prune.

  • Before add looks for a holder, it removes each worktree that prune --confirm removes: clean, not locked, not the current directory, and at the head of a merged pull request. It names each with the size of its directory. --no-reclaim skips the step, and --dry-run lists the GitHub reads and removes nothing.
  • A merged worktree still holds its issue, so add 2344 was refused while the merged worktree of chore(deps): update uv to 0.13.6 and Python to 3.14.10 #2344 stood on disk. The reclaim runs before the check for a holder for that reason.
  • The reclaim never stops the work after it. When the pull requests cannot be read, nothing is removed, add says why once (reclaim_error in the JSON) and creates the worktree.
  • prune and the reclaim keep the worktree that holds the current directory, also under --force. Before this, prune --confirm run inside a clean merged worktree removed the directory of the shell.
  • A removed or removable worktree reports its size (size_bytes), and the preview and final lines give the total.
  • CONTRIBUTING.md says what add removes first.

Why add: it is the first command of every piece of work, it clears the worktrees of every agent tool because git lists them all, and a merged worktree blocks it. The other places fail. The end of devops pr cannot fire, because a person merges after the agent's commands end. devops workspace clean is a manual command like prune. The roadmap jobs do not see a workstation. A side effect of devops gh would remove directories as a hidden effect of an unrelated command. The design of the archived change records each one.

Closes #2338

Plans #2338: add removes the worktrees of merged work before it checks for a holder, and prune keeps the worktree of the current directory and reports sizes.
…zes in prune

prune and the reclaim of add keep the worktree that holds the current directory, also under --force. Each removable worktree reports the size of its directory, and the preview and final lines give the total. Part of #2338.
add runs the rules of prune --confirm before it looks for a holder, because a merged worktree still holds its issue. A reclaim that cannot read the pull requests is reported and does not stop the run. --no-reclaim skips it, and --dry-run lists its GitHub reads. Part of #2338.
Archives 2338-reclaim-merged-worktrees and adds its requirements to the capabilities repos-worktrees-add and repos-worktrees-prune. Closes #2338.
@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 branch rebased onto main at release 0.7.0. An earlier run of the same code failed only on the audit check, for the advisory GHSA-45c3-73f7-pv4m on dnspython. Pull request fix(deps): upgrade dnspython to fix GHSA-45c3-73f7-pv4m #2350 fixed it on main, and the rebase picked it up. The test step took 5 m 3 s with other agents running, just over the 5 minute budget.
  • Red before green: the five new prune tests failed (KeyError: 'size_bytes', and the merged worktree of the current directory was removed). The nine new reclaim tests all failed before the reclaim existed, and all passed with it.
  • Real host: add 9998 --dry-run in the main repository listed 3 reads of pull requests and then the 3 git commands, and changed nothing.
  • Real GitHub, scratch clone: a clone whose origin is the real repository, with a worktree at the head of merged pull request feat(repos): add devops repos worktrees add that refuses a held issue #2348. add 9998 --type chore --slug probe read the pull request from GitHub, removed the worktree (removed …/wt_merged (22.7 MB); du -sb gave 23,779,446 bytes) and created w-9998. A second add removed nothing (reclaimed: [], reclaim_error: null), and add 9998 again was refused, naming the worktree of the first. I removed the scratch clone afterwards. I did not run a real removal in the main repository, since that would remove worktrees of other agent tools.

@dan-petty
dan-petty marked this pull request as ready for review October 27, 2026 16:57
@dan-petty
dan-petty merged commit 6d3a18a into main Oct 27, 2026
16 checks passed
@dan-petty
dan-petty deleted the feat/2338-reclaim-merged-worktrees branch October 27, 2026 20:51
dan-petty pushed a commit that referenced this pull request Oct 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.8.0](v0.7.4...v0.8.0)
(2026-10-27)


### Features

* **github:** devops gh issues view shows one issue
([#2374](#2374))
([63be7ed](63be7ed)),
closes [#2361](#2361)
* **repos:** make devops repos worktrees add remove merged worktrees
first ([#2351](#2351))
([6d3a18a](6d3a18a)),
closes [#2338](#2338)


### Bug Fixes

* **k8s:** devops k8s configure-urls saves a run that changes only the
task gateway urls
([#2384](#2384))
([1a7e7c7](1a7e7c7))
* **k8s:** exit non-zero when kube-linter is unavailable or reports
findings ([#2386](#2386))
([31c5a0b](31c5a0b)),
closes [#2095](#2095)
* **scan:** serialize status and reason in JSON and YAML scan output
([#2385](#2385))
([d594b55](d594b55))

---
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): remove worktrees whose commits are merged without a manual prune

1 participant