Skip to content

Add command for pruning worktrees#62

Merged
bjester merged 4 commits into
release-v0.5.xfrom
prune
Jun 15, 2026
Merged

Add command for pruning worktrees#62
bjester merged 4 commits into
release-v0.5.xfrom
prune

Conversation

@bjester

@bjester bjester commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Adds command prune which can be used to prune worktrees. It works by searching the default configured Github repository for PRs with matching head branches that have been merged. It validates head commit of each matches before prompting the user to remove it. By default it also deletes the branch.

The remove command also has a new flag that enables optional removal of the worktree branch.

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

🎉 Build Assets are ready!

Type File Checksum
Wheel treefort-0.5.0b0-py3-none-any.whl 42a4b5196d1158539b9102abc239017865c0e13c6189c69daa61cb6dd92aa507
PEX treefort.pex b0645ecba0b6c9f38e2da2d84233cff89d0ac5a6301b0ac24543180e3e3a8394
Binary (amd64) treefort-linux-amd64 e17ea23742eda3159ff745f8dd2bf194187d863667048e8d548c669fcc59fe74
Binary (arm64) treefort-linux-arm64 1342019dbb9a84212c80c037f976cefec4c5e90bbbe7c974a29edf9e17affed5

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new prune command to automatically clean up worktrees and local branches associated with merged pull requests, and adds a --delete-branch option to the remove command. The review feedback focuses on improving robustness and security, including handling potential TypeErrors when parsing PR heads, ensuring post-remove hooks run even if branch deletion fails, using Path comparisons and removeprefix for safer path and string manipulation, and appending -- to Git commands to prevent argument injection.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/treefort/commands/prune.py Outdated
Comment thread src/treefort/commands/prune.py Outdated
Comment thread src/treefort/commands/prune.py Outdated
Comment thread src/treefort/commands/prune.py Outdated
Comment thread src/treefort/git.py Outdated
Comment thread src/treefort/git.py
@bjester

bjester commented Jun 15, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new prune command to clean up worktrees and local branches associated with merged pull requests, and adds a --delete-branch option to the remove command. The review feedback suggests importing Path in remove.py to avoid potential name errors, updating the git mock in test_remove.py to include list_worktrees, and using .resolve() when comparing paths in prune.py to handle path representation differences robustly.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/treefort/commands/remove.py
Comment thread tests/commands/test_remove.py
Comment thread src/treefort/commands/prune.py Outdated
@bjester bjester merged commit 3ccd928 into release-v0.5.x Jun 15, 2026
15 checks passed
@bjester bjester deleted the prune branch June 15, 2026 00:53
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