RFR: 2242: Creating pull request on github assumes source is personal fork of user

Erik Joelsson erikj at openjdk.org
Thu Apr 25 21:39:53 UTC 2024


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.

-------------

Commit messages:
 - SKARA-2242

Changes: https://git.openjdk.org/skara/pull/1641/files
  Webrev: https://webrevs.openjdk.org/?repo=skara&pr=1641&range=00
  Issue: https://bugs.openjdk.org/browse/SKARA-2242
  Stats: 84 lines in 3 files changed: 73 ins; 3 del; 8 mod
  Patch: https://git.openjdk.org/skara/pull/1641.diff
  Fetch: git fetch https://git.openjdk.org/skara.git pull/1641/head:pull/1641

PR: https://git.openjdk.org/skara/pull/1641


More information about the skara-dev mailing list