Describe the bug
When pr status is run, it looks at the current branch and then tries to fetch PRs based on the current branch. When PRs might be cross-org, the ref is prefixes with <owner>: to signify this to the API.
Since v2.66.0 which started respecting @{push} and friends, this stopped working. This is because previously, there was code to append the prefix which was removed: https://github.com/cli/cli/pull/9208/files#diff-9776f6be3a596e91eeb946779f87bfe92859332fdda85b07eaa07a433728e4fdL233
The replacement code only uses the branch name.
This acceptance test demonstrates the issue (passes on v.2.65.0 and fails after v.2.66.0). The assertion could be improved but it does the trick to demonstrate the issue.
#skip 'it creates a fork owned by the user running the test'
# Setup environment variables used for testscript
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
env FORK=${REPO}-fork
# Use gh as a credential helper
exec gh auth setup-git
# Get the current username for the fork owner
exec gh api user --jq .login
stdout2env USER
# Create a repository to act as upstream with a file so it has a default branch
exec gh repo create ${ORG}/${REPO} --add-readme --private
# Defer repo cleanup of upstream
defer gh repo delete --yes ${ORG}/${REPO}
# Create a user fork of repository. This will be owned by USER.
exec gh repo fork ${ORG}/${REPO} --fork-name ${FORK}
sleep 5
# Defer repo cleanup of fork
defer gh repo delete --yes ${USER}/${FORK}
# Retrieve fork repository information
exec gh repo view ${USER}/${FORK} --json id --jq '.id'
stdout2env FORK_ID
# Clone the repo
exec gh repo clone ${USER}/${FORK}
cd ${FORK}
# Prepare a branch where changes are pulled from the upstream default branch but pushed to fork
exec git checkout -b feature-branch
exec git commit --allow-empty -m 'Empty Commit'
exec git push -u origin feature-branch
# Create the PR spanning upstream and fork repositories
exec gh pr create --title 'Feature Title' --body 'Feature Body'
stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
# Assert that the PR was created with the correct head repository and refs
exec gh pr status
! stdout 'There is no pull request associated with'
Notes
I intend to fix this as part of work on #575
Describe the bug
When
pr statusis run, it looks at the current branch and then tries to fetch PRs based on the current branch. When PRs might be cross-org, the ref is prefixes with<owner>:to signify this to the API.Since
v2.66.0which started respecting@{push}and friends, this stopped working. This is because previously, there was code to append the prefix which was removed: https://github.com/cli/cli/pull/9208/files#diff-9776f6be3a596e91eeb946779f87bfe92859332fdda85b07eaa07a433728e4fdL233The replacement code only uses the branch name.
This acceptance test demonstrates the issue (passes on
v.2.65.0and fails afterv.2.66.0). The assertion could be improved but it does the trick to demonstrate the issue.Notes
I intend to fix this as part of work on #575