Repository navigation
fix(action): create-pr can update its PR branch on later runs - #2
Merged
Merged
Conversation
actions/checkout only fetches the triggering ref, so there is no refs/remotes/origin/<pr-branch> on the runner and a bare --force-with-lease is rejected (stale info) once the branch exists. scripts/push_pr_branch.sh reads the branch tip with ls-remote and leases on that exact value (empty when absent), which works for both the checkout-style wildcard refspec and single-branch clones. Tests simulate two scheduled runs against a local bare remote. Also: document fail: false alongside create-pr; note pr_body.py is Action-only.
|
Owner
Author
|
Reviewed against GOAL.md: this is in scope. It makes the "apply that change safely" part of Checked
Nit (non-blocking)
Looks good to merge once CI is green. |
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.
Follow-up to #1 (review: #1 (comment)), which was merged before this was fixed.
Bug:
actions/checkoutonly fetches the triggering ref, so the runner has norefs/remotes/origin/<pr-branch>.git push --force-with-leasewith no tracking ref expects the branch to be absent, so every run after the first was rejected (stale info) and the "Updated PR #N" path was unreachable.Fix: new
scripts/push_pr_branch.sh(called fromaction.yml) reads the branch tip withgit ls-remoteand pushes with an explicit lease--force-with-lease=refs/heads/<branch>:<sha>(empty sha = must not exist). Fetch-only (the review suggestion) is not enough with a single-branch refspec: git still can't map the branch to a tracking ref, which the new test caught. The explicit lease works for both, and it still refuses to clobber a branch that moved after the lookup.Tests:
tests/test_action_push.pybuilds a local bare remote, simulates two scheduled runs (checkout-style and single-branch clones), checks the second push updates the branch, checks the lease still protects a moved branch, and pins the original bug (bare lease → stale info). Skipped on Windows.Minor review points:
create-prinput description + docs table now say to pair it withfail: false;pr_body.pydocstring notes it's Action-only (not in the wheel).CHANGELOG and
.github/release-notes/v0.3.0.mdupdated. No tag or release.