Repository navigation
fix: check git ref directly when pushing signed commits - #4521
Merged
Merged
Conversation
The branches API follows branch rename redirects, so a branch name that was previously renamed resolves to the renamed branch. This caused the ref to be reported as existing, and the subsequent updateRef failed with 'Reference does not exist'. Check the git ref directly instead, which is the same ref that is then created or updated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Full test suite slash command (repository admin only) |
Owner
Author
|
/test repository=peter-evans/create-pull-request ref=peter-evans-laughing-giggle build=true sign-commits=true |
peter-evans
marked this pull request as ready for review
November 10, 2026 12:42
sdwilsh
pushed a commit
to sdwilsh/ansible-playbooks
that referenced
this pull request
Nov 10, 2026
…2130) ##### [\`v8.1.3\`](https://github.com/peter-evans/create-pull-request/releases/tag/v8.1.3) #### What's Changed - fix: check git ref directly when pushing signed commits by [@peter-evans](https://github.com/peter-evans) in [#4521](peter-evans/create-pull-request#4521) - Update distribution by [@actions-bot](https://github.com/actions-bot) in [#4526](peter-evans/create-pull-request#4526) **Full Changelog**: <peter-evans/create-pull-request@v8.1.2...v8.1.3> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.
Fixes #4502
Summary
With
sign-commits: true,createOrUpdateRefdecides whether to create or update the pull request branch usingrepos.getBranch. The branches API follows branch rename redirects. If a branch was ever renamed from the pull request branch name,GET /repos/{owner}/{repo}/branches/{name}returns the renamed branch instead of a 404. For example, on this repositoryGET /branches/masterreturnsmain.The action then treats the branch as existing and calls
updateRef, which fails withReference does not exist. The git-based steps don't hit this because git operations never follow rename redirects.This PR checks the ref directly with
git.getRef(GET /repos/{owner}/{repo}/git/ref/heads/{branch}):GET /git/ref/heads/masterreturns 404 on this repository).Changes
src/github-helper.ts: usegit.getRefinstead ofrepos.getBranchincreateOrUpdateRef.__test__/github-helper.unit.test.ts: add a regression test for a branch name that only resolves through a rename redirect, which now creates the ref; add a test that an existing branch is still updated; switch the existing submodule test's mock fromgetBranchtogetRef.Alternative considered
Keep
repos.getBranchand treat the branch as existing only whendata.name === branch. That also fixes the bug, but it infers the answer from the branches API's response rather than checking the ref that's about to change.dist/is not updated here; CI regenerates it after merge.