Repository navigation
2.66.0 regression: gh pr create doesn't work any more with triangular workflows #10346
Copy link
Copy link
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workingcoreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsgh-prrelating to the gh pr commandrelating to the gh pr commandmore-info-neededMore info needed from user/contributorMore info needed from user/contributorneeds-triageneeds to be reviewedneeds to be reviewedpriority-2Affects more than a few users but doesn't prevent core functionsAffects more than a few users but doesn't prevent core functions
Description
Describe the bug
gh pr create appears to always crash on a local repo with more than one remote. Specifically, an error is raised when checking for an existing PR. This happens regardless if already pushed my branch to one of the remotes or not.
$ gh pr create
? Where should we push the 'dep/bump_matplotlib_3.6.0' branch? <origin>
error checking for existing pull request: no remote for "neutrinoceros:<branch_name>@{push}" found in "upstream, origin"
$ git push --set-upstream origin <branch_name>
$ gh pr create
error checking for existing pull request: no remote for "neutrinoceros:<branch_name>@{push}" found in "upstream, origin"
Affected version
This is a regression in 2.66.0 . 2.65.0 worked fine for me.
Steps to reproduce the behavior
$ git clone [email protected]:neutrinoceros/cli.git
$ cd cli
$ git remote add upstream https://github.com/cli/cli
$ git switch -c testbranch
$ echo "hello world" > testfile.txt
$ git add testfile.txt
$ git commit -am "test commit"
$ gh repo set-default
<cli/cli>
$ gh pr create
? Where should we push the 'testbranch' branch? neutrinoceros/cli
error checking for existing pull request: no remote for "neutrinoceros:testbranch@{push}" found in "upstream, origin"
Expected vs actual behavior
gh pr create should still work in a triangular workflow
Logs
$ GH_DEBUG=true gh pr create
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
* Request at 2025-01-31 10:53:57.39598 +0100 CET m=+0.125380751
* Request to https://api.github.com/graphql
* Request took 389.563792ms
[git symbolic-ref --quiet HEAD]
[git status --porcelain]
[git config --get-regexp ^branch\.testbranch\.(remote|merge|pushremote|gh-merge-base)$]
[git show-ref --verify -- HEAD refs/remotes/upstream/testbranch refs/remotes/origin/testbranch]
* Request at 2025-01-31 10:53:57.858646 +0100 CET m=+0.588045959
* Request to https://api.github.com/graphql
* Request took 348.268709ms
* Request at 2025-01-31 10:53:58.241026 +0100 CET m=+0.970424584
* Request to https://api.github.com/graphql
* Request took 203.035125ms
? Where should we push the 'testbranch' branch? neutrinoceros/cli
[git -c log.ShowSignature=false log --pretty=format:%H%x00%s%x00%b%x00 --cherry upstream/trunk...testbranch]
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
[git config --get-regexp ^branch\.neutrinoceros:testbranch\.(remote|merge|pushremote|gh-merge-base)$]
[git remote -v]
⣾[git config --get-regexp ^remote\..*\.gh-resolved$]
[git config push.default]
[git rev-parse --abbrev-ref neutrinoceros:testbranch@{push}]
[git config remote.pushDefault]
error checking for existing pull request: no remote for "neutrinoceros:testbranch@{push}" found in "upstream, origin"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcoreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsgh-prrelating to the gh pr commandrelating to the gh pr commandmore-info-neededMore info needed from user/contributorMore info needed from user/contributorneeds-triageneeds to be reviewedneeds to be reviewedpriority-2Affects more than a few users but doesn't prevent core functionsAffects more than a few users but doesn't prevent core functions
Activity
andyfeller commentedon Jan 31, 2025
Thank you for raising this issue up, @neutrinoceros! 🙇 Let me see about digging into this and working with the other maintainers regarding the changes from #9208.
andyfeller commentedon Jan 31, 2025
@neutrinoceros : Could you share a few more details to help narrow down why this might be an issue, please?
git config --listdetails of the repository in your examplegit versionReproduction attempt
Using a fork based on https://github.com/tinyfists/gh-nonsense, I'm attempting to reproduce this with a different fork/upstream as I want to avoid testing against
cli/cli.os: MacOS 14.17.1
git: 2.46.0
In the last step,
gh pr createdoes not error and continues on to prompt me for completing the PR creation.Clone fork outside of
gh repo cloneand setup remoteCreate
testbranchfrom reproduction stepsSetup default remote and create PR
Relevant code
cli/pkg/cmd/pr/create/create.go
Lines 312 to 321 in 42c0cb0
cli/pkg/cmd/pr/shared/finder.go
Lines 305 to 327 in 42c0cb0
cli/pkg/cmd/pr/shared/finder.go
Lines 69 to 71 in 42c0cb0
cli/git/client.go
Lines 476 to 483 in 42c0cb0
neutrinoceros commentedon Jan 31, 2025
Thanks for working on this. Here are some more details
git config listoutput
credential.helper=osxkeychain user.name=<redacted> user.email=<redacted> init.defaultbranch=main merge.conflictstyle=zdiff3 diff.algorithm=histogram rerere.enabled=true branch.sort=-committerdate rebase.autostash=true rebase.autosquash=true alias.squash=!f() { : git show ; git -c sequence.editor=: rebase -i ${1:-@~10}; }; f alias.gone=! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '$2 == "[gone]" {print $1}' | xargs -r git branch -D alias.switch-recent=!git branch --sort=-committerdate --format='%(refname:short)' | fzf --preview='git log --date=relative --color main..{}' | xargs git switch alias.primary=!f() { git branch -a | sed -n -E -e '/remotes.origin.ma(in|ster)$/s@remotes/origin/@@p'; }; f alias.ma=!f() { git checkout $(git primary) && git pull; }; f alias.maup=!f() { git ma && git pull upstream $(git primary) --ff-only && git push; }; f core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true core.ignorecase=true core.precomposeunicode=true [email protected]:neutrinoceros/gh-nonsense.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.main.remote=origin branch.main.merge=refs/heads/main remote.upstream.url=https://github.com/tinyfists/gh-nonsense remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/* remote.upstream.gh-resolved=baseI'm on MacOS 15.2
gaborbernat commentedon Jan 31, 2025
I'm running into the same issue 🤔
jtmcg commentedon Feb 1, 2025
Hey @neutrinoceros and @gaborbernat, I managed to mostly reproduce this locally on
v2.66.0, but we shipped a hotfix today for #10352 that I suspect addresses this issue as well. I've tried to repro using the steps that gave me the same error you have reported here and things were behaving as expected.Could y'all give this another go once you upgrade to
v2.66.1and let us know if this is fixed for you? Thanks!jaymzh commentedon Feb 1, 2025
I can confirm 2.66.1 fixes this for me.
neutrinoceros commentedon Feb 1, 2025
Me too ! Thanks for promptly addressing this issue !
ssbarnea commentedon Feb 1, 2025
@neutrinoceros time to close it.
katty115 commentedon Feb 17, 2025