Include headRepositoryId when creating a new PR#10253
Draft
jacob-keller wants to merge 1 commit intocli:trunkfrom
Draft
Include headRepositoryId when creating a new PR#10253jacob-keller wants to merge 1 commit intocli:trunkfrom
jacob-keller wants to merge 1 commit intocli:trunkfrom
Conversation
gh pr create does not currently handle creating pull requests across repositories in the same organization. If a user attempts to create such a PR, they will see a confusing error message: pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between innersource:main and sandbox:branch, Head ref must be a branch (createPullRequest) According to the API documentation, to create such a pull request, the API request must contain the headRepositoryId identifying where the PR branch exists. In the usual case where gh pr create is being called without arguments, the head repository is already known. It is looked up in order to ensure the local changes are pushed to the remote fork. In submitPR, extract the repository ID from the headRepo. If the headRepo is already a full repository object, just grab the ID from it. Otherwise perform an additional API lookup to get the repository object and then grab the ID from that. Extend the CreatePullRequest API wrapper to pass the headRepositoryId if it was given. This partially fixes cli#10238, at least in cases where the head repository is known. A different solution will be required for the general case where --head is used.
84606c4 to
f5b50e0
Compare
Author
|
Ok, I got my system setup to build, and fixed the issues compiling. I haven't yet figured out how to resolve the tests failing, since we now issue another HTTP API request to get the repository object for a few of the tests. |
Author
|
I'm still unable to figure out how to get the tests to pass, but I did try this manually and it resolved my issues with creating pull requests. |
This comment was marked as spam.
This comment was marked as spam.
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.
gh pr create does not currently handle creating pull requests across
repositories in the same organization. If a user attempts to create such a
PR, they will see a confusing error message:
pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between innersource:main and sandbox:branch, Head ref must be a branch (createPullRequest)
According to the API documentation, to create such a pull request, the API
request must contain the headRepositoryId identifying where the PR branch
exists.
In the usual case where gh pr create is being called without arguments, the
head repository is already known. It is looked up in order to ensure the
local changes are pushed to the remote fork.
In submitPR, extract the repository ID from the headRepo. If the headRepo
is already a full repository object, just grab the ID from it. Otherwise
perform an additional API lookup to get the repository object and then grab
the ID from that.
Extend the CreatePullRequest API wrapper to pass the headRepositoryId if it
was given.
This partially fixes #10093, at least in cases where the head repository is
known. A different solution will be required for the general case where
--head is used.