Repository navigation
fix: delete sync branches that auto-delete misses - #61
Merged
Merged
Conversation
GitHub's automatically-delete-head-branches skips merges made with an app token, and the sync's auto-merge runs with GITHUB_TOKEN, so 52 merged sync branches had piled up. Each run now deletes merged sync branches that still point at their merged head, and closing a superseded sync PR deletes its branch.
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 1
Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…anup Covers superseded (closed) PRs in the cleanup step instead of passing --delete-branch to gh pr close, which would delete a branch name the current run reuses. Skips names an open PR uses, warns on non-404 read errors, drops the stale tracking ref after a delete, and marks the step continue-on-error.
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.
Problem
The repo has "Automatically delete head branches" on, but 52 merged sync branches had piled up. GitHub skips that cleanup when an app token does the merge (community discussion #63409). The sync's auto-merge is enabled with
GITHUB_TOKEN, so every one of those PRs showsmergedBy: app/github-actions. The two sync PRs merged by a person (#3, #60) were cleaned up normally.Auto-delete also never applies to a closed PR, so the branch of each superseded sync PR that "Close stale sync PRs" closes is left behind too.
The 56 leftover branches were deleted by hand on 2026-10-19. 52 of them still pointed at their merged PR heads. The other 4 had no PR and held only stale rebased copies of the original port commit, whose one unique file, the
supertoolsymlink, had been removed from main on purpose (0e061ce).Fix
A new step, "Delete finished sync branches", runs before upstream is fetched on every scheduled run, including runs with no upstream change. It uses only
gh api, so no upstream code runs with its token.sync/*PR, if the branch still exists and still points at that PR's head.refs/remotes/origin/<branch>. Otherwise a laterpush --force-with-leaseof the same name in this run would fail its lease.continue-on-errorwith a 5-minute timeout, so a cleanup failure or hang never blocks the sync. It setsshell: bash, because the defaultbash -ehas no pipefail and would show a failedgh pr listas a green step."Close stale sync PRs" is unchanged. Passing it
--delete-branchwas the first version of this PR. It was dropped because it would also delete a branch name that the current run is reusing.Verification
bash -eo pipefail, as Actions runs it, with three throwaway branches and their local tracking refs:sync/manual-2026-10-19, at merged chore: sync with cursor/plugins — chore(pstack): bump to 0.15.28, sync guide with create-formal-verification-skill (#724) #60's headea04fe4, was deleted and its tracking ref removed.sync/docs-pstack-port-workflow-and-boundary-guidance-238-7-commits, at closed chore: sync with cursor/plugins — docs(pstack): port workflow and boundary guidance (#238) #26's heada2c2ace, was deleted and its tracking ref removed.sync/feat-pstack-add-poteto-help-skill-502, pointed at main instead of chore: sync with cursor/plugins — feat(pstack): add /poteto-help skill (#502) #57's head, was kept with the "moved" warning.mainand this PR's branch remain.sync/head is excluded, and an opensync/a-2does not shield a closedsync/a: the match is exact.ghto reach the error branches. A 404 is silent, an HTTP 502 read gives "could not read", a failed delete gives "could not delete", and the script exits 0.actionlintreports only the SC2129 style note that already exists on main. SC2016 is suppressed in the script, because$openand$namethere are jq variables.