RFR: 2242: Creating pull request on github assumes source is personal fork of user
Zhao Song
zsong at openjdk.org
Fri Apr 26 00:59:39 UTC 2024
On Thu, 25 Apr 2024 21:35:43 GMT, Erik Joelsson <erikj at openjdk.org> wrote:
> This patch fixes the behavior of `GitHubRepository::createPullRequest`. The API pretty clearly indicates that it's meant to create a pull request from the called repository, to the target repository provided as argument. Instead it creates a pull request from the fork owned by the current user to the target repository provided as argument. If the current user has `[bot]` in the name, then the PR will be created using the target repository as source instead. In either case, the called repository is ignored and sometimes just happens to coincide with the fork of the current user.
>
> The existing behavior is perplexing but I'm pretty sure I'm right. I'm changing it to explicitly take the "group" value of the called repository as "namespace" instead. This will equal the username when the called repository is a user fork, or the group/org if the called repository is in a GitHub org. In the case where source and target are the same repo, it will also do the right thing.
>
> In addition to this error, I noted that the returned PullRequest instance is inconsistent. It is given the HostedRepository of the target, which is correct, but the `request` object of the called repository, which is wrong. This caused all calls to the returned PullRequest object to return 404. In MergeBot, this was worked around by explicitly fetching a new instance from the target repository. By fixing this, that workaround in MergeBot could be removed.
>
> I added three manual/integration tests for this that I have manually verified using the playground repository, my personal fork of the same and the fork in the openjdk-bots org.
Looks pretty good!
-------------
Marked as reviewed by zsong (Reviewer).
PR Review: https://git.openjdk.org/skara/pull/1641#pullrequestreview-2023853494
More information about the skara-dev
mailing list