Bug 544815 - Support Github pull request integration similar to "Fetch from Gerrit"
Summary: Support Github pull request integration similar to "Fetch from Gerrit"
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement with 3 votes (vote)
Target Milestone: 6.0   Edit
Assignee: Thomas Wolf CLA
QA Contact:
URL:
Whiteboard:
Keywords: consistency, helpwanted, usability
Depends on: 574067 575567
Blocks: 576841
  Show dependency tree
 
Reported: 2019-02-26 06:35 EST by Lars Vogel CLA
Modified: 2022-03-29 09:12 EDT (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2019-02-26 06:35:37 EST
Currently Egit provides a very strong EGit integration. It currently does not support the integration of Github Pullrequests. 

Command line process is described here:
https://help.github.com/en/articles/checking-out-pull-requests-locally

Would be great if EGit would support to fetch Github pull requests as easy as Gerrit requests.
Comment 1 Thomas Wolf CLA 2019-02-26 07:39:38 EST
There is already code for some PR-related commands (checkout PR, merge PR, rebase PR), but I don't see them used anywhere in the code or in plugin.xml. Probably also limited to the GitHub HTTPS API.

Looks like that part was never finished?

I see two problems:

1. The refs/pull namespace is read-only, so you can't push new commits
   onto a PR that way.

2. How to detect that a repo is a GitHub repo? In the worst case the user
   might need to configure the clone explicitly, like it was once necessary
   for Gerrit, too. (We still have the "Gerrit Configuration..." command.)
   It might also be a self-hosted GitHub Enterprise server, so looking at the
   URL is not good enough. Querying whether the server advertises
   refs/pull/*/head refs might perhaps work, but might fail if
   there are other servers that happen to use the same namespace for
   something else. Gitlab EE uses refs/merge-requests/*/head,[1] Bitbucket
   Server uses refs/pull-requests/*/from and refs/pull-requests/*/merged.[2]

Finally, working with pull requests isn't limited to GitHub. Would be nice if there was some general support.

If this can be done simply via refs, it should also work over ssh.

[1] https://docs.gitlab.com/ee/user/project/merge_requests/#checkout-locally-by-modifying-gitconfig-for-a-given-repository
[2] https://stackoverflow.com/questions/53889035/bitbucket-server-api-get-raw-files-associated-with-pull-request
Comment 2 Matthias Sohn CLA 2019-02-27 18:15:30 EST
(In reply to Lars Vogel from comment #0)
> Currently Egit provides a very strong EGit integration.

I guess you meant Gerrit integration :-?
Comment 3 Michael Keppler CLA 2019-03-01 08:18:37 EST
Regarding read-only references: My gut feeling says that a service specific number-to-URI translation is necessary in all cases, which does more than adding the number to a fixed URI prefix. I.e. we should rather ask github for the source URI of the PR instead of trying to use the read-only URI. The same has already been done for gerrit.

Regarding github enterprise: I feel this feature would be worth implementing just for github.com alone, totally ignoring the enterprise version. Think of 80/20 rule.
Comment 4 Michael Keppler CLA 2019-03-19 12:36:57 EDT
I found this actually already works.

* Create a Mylyn task repository of type Github/Pull Requests (requires mylyn-github connector installed, as described before).
* Create Mylyn query for open PRs on a project you like.
* Open a PR from the Mylyn Task list view.
* In the upper right of the form based editor for the PR there is an icon "Fetch commits from PR", which will fetch into the matching git repo.
Comment 5 Matthias Sohn CLA 2019-03-19 13:11:06 EDT
:-)

So this just needs a bit polishing to make it more accessible.
We could add a command similar to "Configure Gerrit" on the remote for the repository on Github and create the Mylyn PR query under the hood ?
Comment 6 Lars Vogel CLA 2019-04-15 05:55:14 EDT
Feature now available in IntelliJ https://www.jetbrains.com/idea/whatsnew/#v2019-1-version-control
Comment 7 Michael Keppler CLA 2019-04-15 15:17:57 EDT
More like https://www.jetbrains.com/idea/whatsnew/#v2018-3-version-control :)
Comment 8 Ralf Hauser CLA 2020-02-06 08:31:56 EST
The 4 or more points of comment 4 sound quite complicated.
So I fully agree with Matthias needs to be simplified / more accessible by ""menu support" (see also bug 559856)
Comment 9 Mickael Istria CLA 2020-07-30 07:31:24 EDT
I'd like to see, without having to install Mylyn task, just an operation to checkout a random remote reference; ideally accessible from the Switch To submenus.
Once we have such switch to, then it becomes only a matter of selecting the github repo and using the pulls/123/head reference (where 123 is PR name).
Then, in another operation, we could imagine a switch to > Pull Request operation that would take care of opening a dialog to help getting the GitHub PR with just the PR number or URL (or later with some search key or whatever helps).
All that could/should ideally work without Mylyn tasks.
Comment 10 Lars Vogel CLA 2021-03-18 07:08:15 EDT
On the push side a "Create a PR after this push" would be great. I frequently work in a branch, e.g., master and would like verify the change via Jenkins / build actions. So far I have to push to a new branch and switch to a browser to create a PR.
Comment 11 Jay Arthanareeswaran CLA 2021-09-29 00:24:13 EDT
I see no activity here for a while now. It would be good to have people discuss and share their thoughts what the feature should look like.
Comment 12 Mickael Istria CLA 2021-09-29 19:06:27 EDT
(In reply to Thomas Wolf from comment #1)
> 1. The refs/pull namespace is read-only, so you can't push new commits
>    onto a PR that way.

IMO, we can start by just suppprting Ferch/Switch to ease reviews. Support for push can come later, especially since GitHib allow different strategies to update a PR (append or force push,os the initial PR mine or not...?) Are acceptable, it's tricky to giess user ezpextations for push.

> 2. How to detect that a repo is a GitHub repo?

IMO, alhtough it's incomplete, we could start by just supporting repositories from the guthub.com domain. That would be easy to start with and cover most of cases.

(In reply to Jay Arthanareeswaran from comment #11)
> I see no activity here for a while now. It would be good to have people
> discuss and share their thoughts what the feature should look like.

At this stage, I think we need more details to prioritize and drive actual dwcelopment work. Can you please elaborate which specific features you('d) need on a daily usage?
Comment 13 Eclipse Genie CLA 2021-10-03 09:22:03 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/186090
Comment 14 Eclipse Genie CLA 2021-10-03 09:22:06 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/186091
Comment 15 Thomas Wolf CLA 2021-10-03 09:27:04 EDT
Here's a basic implementation that works exactly like the "Fetch From Gerrit..." wizard. That seems to cover the original request in comment 0.

There's still room for future improvements; see the commit message of https://git.eclipse.org/r/c/egit/egit/+/186091 .
Comment 16 Mickael Istria CLA 2021-10-04 05:02:18 EDT
(In reply to Thomas Wolf from comment #15)
> Here's a basic implementation that works exactly like the "Fetch From
> Gerrit..." wizard. That seems to cover the original request in comment 0.

That's really good!
Comment 17 Eclipse Genie CLA 2021-10-06 16:13:12 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/186243
Comment 18 Eclipse Genie CLA 2021-10-10 14:34:40 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/186340
Comment 19 Mickael Istria CLA 2021-10-11 04:53:15 EDT
@Thomas: do you think you could already merge your 1st patch so we could benefit from it by updating to a snapshot build already?
Comment 20 Thomas Wolf CLA 2021-10-11 04:57:27 EDT
For alpha testing, you could also install EGit from the temporary update site produced by the Jenkins CI.

Download https://ci.eclipse.org/egit/job/egit.gerrit/2420/artifact/org.eclipse.egit.repository/target/repository/ as ZIP and install from that archive. (Or expand the archive and install from the file system. I've had troubles with ZIP archives in the past.)
Comment 25 Thomas Wolf CLA 2021-10-13 05:32:36 EDT
Preliminary N&N at [1].

[1] https://wiki.eclipse.org/EGit/New_and_Noteworthy/6.0#Fetching_Pull_Requests
Comment 26 Mickael Istria CLA 2021-10-13 05:53:07 EDT
I just installed the snapshot and am already happily extensively using it! Thanks!
Comment 27 Lars Vogel CLA 2021-10-22 07:22:59 EDT
Thanks, Thomas for fixing it. I opened Bug 576841 for an enhancement of the labels.
Comment 28 Jay Arthanareeswaran CLA 2021-10-27 05:07:18 EDT
Thanks for taking care of this!

Just noticed that it only works for github.com and not for github.abc.com. Is there a reason why this isn't working for me?
Comment 29 Thomas Wolf CLA 2021-10-27 05:39:05 EDT
(In reply to Jay Arthanareeswaran from comment #28)
> Thanks for taking care of this!
> 
> Just noticed that it only works for github.com and not for github.abc.com.
> Is there a reason why this isn't working for me?

See the N&N for the upcoming EGit 6.0 for what to do[1]: define your own URL patterns.

[1] https://wiki.eclipse.org/EGit/New_and_Noteworthy/6.0#Configuring_Hosts_for_Pull_Requests
Comment 30 Thomas Wolf CLA 2021-10-27 05:44:07 EDT
(In reply to Thomas Wolf from comment #29)
> See the N&N for the upcoming EGit 6.0 for what to do[1]: define your own URL
> patterns.
> 
> [1]
> https://wiki.eclipse.org/EGit/New_and_Noteworthy/6.
> 0#Configuring_Hosts_for_Pull_Requests

And if you're wondering why it's different between Github and Gitlab: I am aware of at least two open-source projects using Gitlab and publishing at gitlab.abc.org: gitlab.eclipse.org and gitlab.gnome.org. So I included gitlab.<somedomain>.{com,org} by default. I'm not aware of any open-source project using github.abc.org, so I didn't include it.

If someone runs Gitlab EE or Github Enterprise on other URLs, custom URL patterns can be defined.
Comment 31 Jay Arthanareeswaran CLA 2021-10-27 08:30:44 EDT
(In reply to Thomas Wolf from comment #29)
> See the N&N for the upcoming EGit 6.0 for what to do[1]: define your own URL
> patterns.
> 
> [1]
> https://wiki.eclipse.org/EGit/New_and_Noteworthy/6.0#Configuring_Hosts_for_Pull_Requests
> 

Awesome and thanks! Works like a charm.
Comment 32 Pierre-Yves Bigourdan CLA 2021-11-07 04:20:42 EST
The new feature works well. Thanks for the good work!
Comment 33 Andrey Loskutov CLA 2022-03-29 07:23:12 EDT
@Thomas: could you please check if there is a regression or just stupid user issue: https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/24#issuecomment-1081745267
Comment 34 Thomas Wolf CLA 2022-03-29 07:41:03 EDT
(In reply to Andrey Loskutov from comment #33)
> @Thomas: could you please check if there is a regression or just stupid user
> issue:
> https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/
> issues/24#issuecomment-1081745267

Can't verify right now (will have to wait until tonight), but I'd be surprised if there was a regression. No changes in that area since the feature was introduced. Show your git config, please.
Comment 35 Andrey Loskutov CLA 2022-03-29 07:59:45 EDT
(In reply to Thomas Wolf from comment #34)
> (In reply to Andrey Loskutov from comment #33)
> > @Thomas: could you please check if there is a regression or just stupid user
> > issue:
> > https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/
> > issues/24#issuecomment-1081745267
> 
> Can't verify right now (will have to wait until tonight), but I'd be
> surprised if there was a regression. No changes in that area since the
> feature was introduced. Show your git config, please.

See https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/24#issuecomment-1081781005

The menu only shows up if the repo url ends with ".git".
Comment 36 Mickael Istria CLA 2022-03-29 08:16:42 EDT
@Andrey: it seems like a limitation in current implementation. I think this should be covered in a separate issue.
Comment 37 Thomas Wolf CLA 2022-03-29 08:38:27 EDT
(In reply to Mickael Istria from comment #36)
> @Andrey: it seems like a limitation in current implementation. I think this
> should be covered in a separate issue.

Yep, open a separate issue that this feature should also handle remote URIs not ending in .git.

If you want to fix it yourself: most probably in GitHosts, line 55. Currently it requires \\.git, changing this to (?:\\.git) should resolve this. ("Probably" because I can't check right now myself; have no access to my EGit dev environment currently.)

On projects in the package/project explorer, the menu item is, like "Fetch from Gerrit...", underneath Team->Remote.
Comment 38 Thomas Wolf CLA 2022-03-29 09:03:02 EDT
(?:\\.git)? of course
Comment 39 Andrey Loskutov CLA 2022-03-29 09:12:54 EDT
(In reply to Thomas Wolf from comment #37)
> (In reply to Mickael Istria from comment #36)
> > @Andrey: it seems like a limitation in current implementation. I think this
> > should be covered in a separate issue.
> 
> Yep, open a separate issue that this feature should also handle remote URIs
> not ending in .git.

I've created bug 579477.