Skip to content

chore(infra): add just worktrees to list work not yet on main - #231

Merged
bordumb merged 2 commits into
mainfrom
claude/optimistic-swartz-worktree-status
Sep 28, 2026
Merged

bordumb merged 2 commits into
mainfrom
claude/optimistic-swartz-worktree-status

Conversation

@bordumb

@bordumb bordumb commented Sep 28, 2026

Copy link
Copy Markdown
Owner

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
Worktrees: 8 of 36 not merged

BRANCH                              MERGED  NOTE
claude/busy-cartwright-7681ff       no      uncommitted: 155 file(s), 151 would change main, conflicts with main
claude/redshift-connect-args        no      1 of 1 commit(s) not on main or in a merged PR; PR #206 closed; [dazzling-faraday-28aa25]
claude/fervent-panini-9a96fa        yes     by title: #170
claude/gallant-boyd-dd7fcb          yes     3 uncommitted file(s), already in #150
...

just worktrees --branches also lists local branches that no worktree has checked out.

How it decides

git branch --merged doesn'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:

  • by sha
  • by stable patch-id
  • by title (main's (#N) squash suffix is stripped); title-only matches are shown as by title: #N

A 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 status runs 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

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

bordumb and others added 2 commits September 28, 2026 21:37
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>
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dataing Ready Ready Preview Sep 28, 2026 8:40pm UTC
dataing-app Ready Ready Preview Sep 28, 2026 8:40pm UTC
dataing-docs Ready Ready Preview Sep 28, 2026 8:40pm UTC

This branch was successfully deployed

3 active deployments
Preview – dataing-docs — 5320da91 Deployed Sep 28, 2026 by vercel[bot]
Preview – dataing — 5320da91 Deployed Sep 28, 2026 by vercel[bot]
Preview – dataing-app — 5320da91 Deployed Sep 28, 2026 by vercel[bot]
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.

1 participant