feat(create-pr): add reuse_branch to keep one self-updating pull request - #80
Open
marc0olo wants to merge 1 commit into
Open
feat(create-pr): add reuse_branch to keep one self-updating pull request#80marc0olo wants to merge 1 commit into
marc0olo wants to merge 1 commit into
Conversation
marc0olo
force-pushed
the
feat/create-pr-reuse-branch
branch
from
August 3, 2026 17:00
5b9249d to
4efc5fc
Compare
This was referenced Aug 3, 2026
create-pr appends a random suffix to branch_name on every run, so each run that finds a diff opens a new branch and a new pull request. While an earlier one is still unmerged, every subsequent run legitimately still sees a diff against the base branch and opens another pull request for it. They accumulate, and once a release lands they all go permanently conflicting. In dfinity/icp-js-core this produced 8 changelog pull requests for 2 distinct changelog states: 3 with byte-identical diffs, and 5 that went conflicting after v6.0.0 shipped and had to be closed unresolved. dfinity/pic-js currently has 6 open, 3 of them conflicting. Adds a reuse_branch input. When enabled, branch_name is used as-is, the branch is reset to the current commit and force pushed, and the pull request already open for it is updated rather than a second one being created. When there is nothing left to propose, that pull request is closed instead of being left to go stale. The input defaults to false, so existing callers such as create-release-pr keep the current behaviour. The generate-changelog reusable workflow opts in by default, since a single self-updating changelog pull request is the intent there. A plain --force is used rather than --force-with-lease: the branch is reset from the base branch on every run, so the local ref never matches the remote one and a lease check would always reject. Closes #77 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
marc0olo
force-pushed
the
feat/create-pr-reuse-branch
branch
from
August 4, 2026 07:30
4efc5fc to
40e8fec
Compare
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.
Closes #77.
create-prappends a random suffix tobranch_nameon every run, so each run that finds a diff opens a new branch and a new pull request. While an earlier one is unmerged, every subsequent run legitimately still sees a diff against the base and opens another for the same content. They accumulate, and once a release lands they all go permanently conflicting, because the release commit folds those entries into a version section.dfinity/icp-js-coreaccumulated 8 changelog pull requests representing 2 distinct changelog states: 3 with byte-identical diffs, and 5 that went conflicting after v6.0.0 and were closed unresolved.dfinity/pic-jscurrently has 6 open, 3 conflicting. This repo produced #82 the same way.This is not about no-op runs —
create-pralready skips when there is nothing to commit. The defect is purely branch reuse.Change
New
reuse_branchinput onactions/create-pr. When enabled:branch_nameis used as-is, with no random suffix.git checkout -B) and force pushed.pulls.createwould return 422 for a duplicate head.New
pull_request_updatedoutput distinguishes an update from a creation;pull_request_createdstays honest and reportsfalsein the update case.Defaults differ deliberately:
falseon the action, so existing callers such ascreate-release-prare unchanged (release branches are already unique per version);trueon thegenerate-changelogreusable workflow, where the accumulation happens. Flagging that explicitly, since it is a behaviour change for the five consuming repos on merge — happy to make it opt-in if you would rather roll it out per repo.--forcerather than--force-with-lease: the branch is reset from the base branch on every run, so the local ref never matches the remote one and a lease check would reject every push. The branch is bot-owned and fully regenerated each run, so there is no human work to clobber.Verification
tscandpnpm buildclean,prettier --check .clean, both changed YAML files parse and the input threads through to the action step. Compiled output confirmed to contain the new behaviour:git checkout -B,git push --force, the reuse branch, and the find/close paths.Not exercised against a live run — that needs a real push to
mainin a consuming repo.Rebased onto
mainafter #79. The bundle conflict I had expected did not materialise: git auto-merged the disjoint regions, and I verified the result matches a freshpnpm buildbyte-for-byte, so no rebuild commit was needed.🤖 Generated with Claude Code