Include headRepositoryId when creating a new PR #10253
Draft
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.