-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Support pr view for intra-org forks
#10078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
BagToad
merged 2 commits into
trunk
from
10077-gh-pr-view-cannot-find-pr-from-branch-when-fork-is-in-the-same-org-as-upstream
Dec 13, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # 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 | ||
|
|
||
| # 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} | ||
| exec gh repo view ${ORG}/${REPO} --json id --jq '.id' | ||
| stdout2env REPO_ID | ||
|
|
||
| # Create a fork in the same org | ||
| exec gh repo fork ${ORG}/${REPO} --org ${ORG} --fork-name ${FORK} | ||
|
|
||
| # Defer repo cleanup of fork | ||
| defer gh repo delete --yes ${ORG}/${FORK} | ||
| sleep 1 | ||
| exec gh repo view ${ORG}/${FORK} --json id --jq '.id' | ||
| stdout2env FORK_ID | ||
|
|
||
| # Clone the fork | ||
| exec gh repo clone ${ORG}/${FORK} | ||
| cd ${FORK} | ||
|
|
||
| # Prepare a branch | ||
| 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, gh pr create does not support headRepositoryId needed for private forks | ||
| exec gh api graphql -F repositoryId="${REPO_ID}" -F headRepositoryId="${FORK_ID}" -F query='mutation CreatePullRequest($headRepositoryId: ID!, $repositoryId: ID!) { createPullRequest(input:{ baseRefName: "main", body: "Feature Body", draft: false, headRefName: "feature-branch", headRepositoryId: $headRepositoryId, repositoryId: $repositoryId, title:"Feature Title" }){ pullRequest{ id url } } }' | ||
|
|
||
| # View the PR | ||
| exec gh pr view | ||
| stdout 'Feature Title' |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change of logic here, just trying to give some words to this conditional.