diff --git a/acceptance/testdata/pr/pr-create-respects-branch-pushremote.txtar b/acceptance/testdata/pr/pr-create-respects-branch-pushremote.txtar index 6f0413a68..aec429280 100644 --- a/acceptance/testdata/pr/pr-create-respects-branch-pushremote.txtar +++ b/acceptance/testdata/pr/pr-create-respects-branch-pushremote.txtar @@ -16,8 +16,6 @@ exec gh repo create ${ORG}/${REPO} --add-readme --private # Defer repo cleanup of upstream defer gh repo delete --yes ${ORG}/${REPO} -exec gh repo view ${ORG}/${REPO} --json id --jq '.id' -stdout2env REPO_ID # Create a user fork of repository. This will be owned by USER. exec gh repo fork ${ORG}/${REPO} --fork-name ${FORK} @@ -40,4 +38,8 @@ exec git push # 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 \ No newline at end of file +stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1 + +# Assert that the PR was created with the correct head repository and refs +exec gh pr view --json headRefName,headRepository,baseRefName,isCrossRepository +stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true} \ No newline at end of file diff --git a/acceptance/testdata/pr/pr-create-respects-push-destination.txtar b/acceptance/testdata/pr/pr-create-respects-push-destination.txtar index 6dd7e6e4f..293850fe2 100644 --- a/acceptance/testdata/pr/pr-create-respects-push-destination.txtar +++ b/acceptance/testdata/pr/pr-create-respects-push-destination.txtar @@ -16,8 +16,6 @@ exec gh repo create ${ORG}/${REPO} --add-readme --private # Defer repo cleanup of upstream defer gh repo delete --yes ${ORG}/${REPO} -exec gh repo view ${ORG}/${REPO} --json id --jq '.id' -stdout2env REPO_ID # Create a user fork of repository. This will be owned by USER. exec gh repo fork ${ORG}/${REPO} --fork-name ${FORK} @@ -40,9 +38,13 @@ exec git checkout -b feature-branch exec git branch --set-upstream-to origin/main exec git rev-parse --abbrev-ref feature-branch@{upstream} stdout origin/main - -# Create the PR exec git commit --allow-empty -m 'Empty Commit' exec git push + +# Create the PR exec gh pr create --title 'Feature Title' --body 'Feature Body' -stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1 \ No newline at end of file +stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1 + +# Assert that the PR was created with the correct head repository and refs +exec gh pr view --json headRefName,headRepository,baseRefName,isCrossRepository +stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true} \ No newline at end of file diff --git a/acceptance/testdata/pr/pr-create-respects-remote-pushdefault.txtar b/acceptance/testdata/pr/pr-create-respects-remote-pushdefault.txtar index cf38d3c9f..37f6ca1f2 100644 --- a/acceptance/testdata/pr/pr-create-respects-remote-pushdefault.txtar +++ b/acceptance/testdata/pr/pr-create-respects-remote-pushdefault.txtar @@ -16,8 +16,6 @@ exec gh repo create ${ORG}/${REPO} --add-readme --private # Defer repo cleanup of upstream defer gh repo delete --yes ${ORG}/${REPO} -exec gh repo view ${ORG}/${REPO} --json id --jq '.id' -stdout2env REPO_ID # Create a user fork of repository. This will be owned by USER. exec gh repo fork ${ORG}/${REPO} --fork-name ${FORK} @@ -41,3 +39,7 @@ exec git push # 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 view --json headRefName,headRepository,baseRefName,isCrossRepository +stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true} \ No newline at end of file diff --git a/acceptance/testdata/pr/pr-create-respects-simple-pushdefault.txtar b/acceptance/testdata/pr/pr-create-respects-simple-pushdefault.txtar index 62d7e700e..ca420bac2 100644 --- a/acceptance/testdata/pr/pr-create-respects-simple-pushdefault.txtar +++ b/acceptance/testdata/pr/pr-create-respects-simple-pushdefault.txtar @@ -1,45 +1,33 @@ -# 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 +# Create a repository with a file so it has a default branch exec gh repo create ${ORG}/${REPO} --add-readme --private -# Defer repo cleanup of upstream +# Defer repo cleanup of repo defer gh repo delete --yes ${ORG}/${REPO} exec gh repo view ${ORG}/${REPO} --json id --jq '.id' stdout2env REPO_ID -# Create a user fork of repository. This will be owned by USER. -exec gh repo fork ${ORG}/${REPO} --fork-name ${FORK} - -# Defer repo cleanup of fork -defer gh repo delete --yes ${USER}/${FORK} -sleep 5 -exec gh repo view ${USER}/${FORK} --json id --jq '.id' -stdout2env FORK_ID - # Clone the repo -exec gh repo clone ${USER}/${FORK} -cd ${FORK} +exec gh repo clone ${ORG}/${REPO} +cd ${REPO} # Configure default push behavior so local and remote branches have to be the same exec git config push.default simple # Prepare a branch where changes are pulled from the default branch instead of remote branch of same name exec git checkout -b feature-branch origin/main - -# Create the PR exec git commit --allow-empty -m 'Empty Commit' exec git push origin feature-branch + +# Create the PR 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 view --json headRefName,headRepository,baseRefName,isCrossRepository +stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${REPO_ID}","name":"${REPO}"},"isCrossRepository":false}