chore(infra): add just worktrees to list work not yet on main - #231
Merged
Merged
Conversation
With a few dozen agent worktrees, "what isn't merged yet?" is hard to answer. `git branch --merged` misses almost every merged branch here, because PRs are squash-merged and the merge train often rebases a branch before merging it. scripts/worktree_status.py prints one line per worktree: the branch, merged yes/no, and for each "no" the reason (commits not landed, PR state, uncommitted files). `just worktrees --branches` also covers local branches that no worktree has checked out. - A branch counts as merged when every commit it adds matches a merged PR's commit or a commit on main: by sha, by patch-id, or by title. Title-only matches are flagged as "by title: #N". - A branch also counts as merged when merging it into main would change nothing. - Uncommitted edits count as merged only when main already has them. The worktree state is snapshotted in a throwaway index and merged onto main with HEAD as the base. This catches PRs that sessions opened straight from another worktree's files. No worktree's index or files change. Standard library only, so it runs with python3 and needs no venv. gh is optional. Needs git 2.40+. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Adds
just worktrees, which answers "what isn't merged yet?" across all local worktrees with one line each: branch, merged yes/no, and why not.just worktrees --branchesalso lists local branches that no worktree has checked out.How it decides
git branch --mergeddoesn't work here: PRs are squash-merged, and the merge train often rebases or re-branches work before merging it. So the script checks the following instead.Committed work. Every commit a branch adds is matched against the commits of all merged PR heads and of main:
(#N)squash suffix is stripped); title-only matches are shown asby title: #NA branch also counts as merged when merging it into main would change nothing.
Uncommitted work. The worktree's changed and untracked files are snapshotted in a throwaway index, then merged onto main with the worktree's HEAD as the base. If that changes nothing, main already has the edits. This covers PRs that sessions opened straight from another worktree's files, and old-base worktrees whose files differ from main only because main moved on. No worktree's index or files are modified, and
git statusruns with--no-optional-locks.It needs only the standard library (plain
python3, no venv) and git 2.40+. gh is optional: without it, commits are matched against main only.Verification
just worktrees --branchesoutput matches the pre-commit scratch version line for line.Also records flow tasks fn-68.5, fn-68.6 and fn-68.8, which were left untracked in this worktree.
🤖 Generated with Claude Code