eclipse-egit / egit

EGit, the git integration of Eclipse IDE

Home Page:https://www.eclipse.org/egit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pasting a GIT URL in the package explorer generates a wrong content.

opcoach opened this issue · comments

Version

6.10.0

Operating System

MacOS

Eclipse version

2024-06

Bug description

I wanted to clone a GIT repository in my current Eclipse using the Copy/Paste command with a GIT URL in my clipboard and I got a wrong content ...

Steps to reproduce

  • Copy this URL (or any other git url) : git@github.com:eclipse-platform/eclipse.platform.ui.git
  • Open the package explorer part
  • Paste inside the view

Actual behavior

In the package explorer view I got this unrelevant result :

image

In the project explorer view I got ... nothing ...

Expected behavior

whatever the 'explorer view' (project explorer view, package explorer view, cdt project view, I would say Common navigator view...) we should get the git clone dialog like in the git repository view.

image

Relevant log output

No response

Other information

Bug fix suggestion : The paste command should be intercepted (on the workbench or on the common navigator view) by egit and taken only if the clipboard contains a text with a git URL pattern. When egit ui plugin starts, it should register its priority paste handler on the workbench... If the paste command is not for him, it passes to the next plugin...

IMO that's not possible.

is a command handler, and a handler cannot just intercept arbitrary other handlers already bound to a command somewhere else, or can it?

Yes we can may be change the active when condition in the handler definition as It is defined only for the repository view.

image

By adding an 'or' condition on other activePartID, that should work...

I wil try it

I got it.. I will provide a solution for this bug using a new Property Tester focused on the clipboard content...

In my implementation I had to make the Git Repository View visible. Is it a problem ? It means that whatever the perspective displayed, the 'Git Repositories' will appear behind the dialog when pasting a 'git url' compliant text. I tried to switch to the git perspective but it is more complicated.

image

Ok, I fixed it definitively ... no problems anymore with the repository view... I now ask if the user wants to switch to the git perspective after the clone (if he was not still there)...

I have done a commit, and I am checking how to contribute using gerrithub as mentioned in the Contributor Guide. Will do that later... Actually the egit repository does not accept standard Pull requests (I guess this is because the GitHub actions to check everything are too expensive ? ) ?

Thanks a lot @opcoach!

You need to push your change to Gerrit at https://eclipse.gerrithub.io, GerritHub uses GitHub for authentication but otherwise it's a Gerrit server.

I pushed it on my fork for the moment, I will check gerrithub tomorrow :) Thanks @msohn

@msohn, I missed the step where I had to request the organization access to eclipse-egit when I signed in gerrithub (as explained in your contribution guide)... I assume the button simply sends an email to grant access... Could you please accept my login (opcoach), to eclipse-egit so that I can push my contribution to gerrithub ?

This shouldn't be necessary since you are not an EGit committer

@msohn thank you. I commented my bug fixing journey in this issue : https://gitlab.eclipse.org/eclipse-wg/ide-wg/community/-/issues/53. Fell free to comment if needed...

I will try to push my patch now...

  • I have checked the remote URL of the GIT repository : it is bound to gerrithub -> Should be ok, and I assume I can push directly and that will create the 'change' on gerrithub.
  • The commit message format must contain the Commit-ID to contain the changes (it is provided in the installed IDE) -> should be ok.
  • I launched a mvn clean verify in the egit repository and it failed because egit and jgit are sibling (org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'jgit' from location file://Users/olivier/egit-master/git/egit/org.eclipse.egit/../../jgit/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/target/repository) ...

I made a commit in a branch (fix48), over the current master (see below) :

image

I have still some questions about the best practices to provide the patch.

  • what are the other steps I could do locally before pushing ?
  • Is that ok to push it directly from eclipse ?
  • Is there still a 'Gerrit' plugin to install in Eclipse to manage changes (I used that some years ago...)...
  • The git remote URL is https://eclipse.gerrithub.io/eclipse-egit/egit, will it use my GitHub credentials ?
  • how can I bind my change to the corresponding issue in the comment ? Is it 'Fix-48' ? (there is no template for that in the default commit message).

Other things :

  • I didn't add the 'file header' voluntary to see if the review will reject my change
  • I didn't add tests also to see if the review will reject it

Sorry to ask these simple questions but I am trying to find the easiest ways to contribute on Eclipse in general and to take the role of a real newbie (which I am actually on this project :)) ...

@msohn thank you. I commented my bug fixing journey in this issue : https://gitlab.eclipse.org/eclipse-wg/ide-wg/community/-/issues/53. Fell free to comment if needed...

I will try to push my patch now...

  • I have checked the remote URL of the GIT repository : it is bound to gerrithub -> Should be ok, and I assume I can push directly and that will create the 'change' on gerrithub.
  • The commit message format must contain the Commit-ID to contain the changes (it is provided in the installed IDE) -> should be ok.

The commit message must contain a "Change-Id:" commit message trailer in the last paragraph.
There is a button in the staging view to add it, when you enabled gerrit on this repo that should happen automatically.
When using git command line install the commit-msg hook, if you try to push without a Change-Id footer Gerrit will respond with instructions how to do that. If you clone using the "Clone URL with commit-msg hook" URL shown here https://eclipse.gerrithub.io/admin/repos/eclipse-egit/egit,general the commit-msg hook is installed automatically.

  • I launched a mvn clean verify in the egit repository and it failed because egit and jgit are sibling (org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'jgit' from location file://Users/olivier/egit-master/git/egit/org.eclipse.egit/../../jgit/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/target/repository) ...

For the maven build follow https://github.com/eclipse-egit/egit/wiki/Contributor-Guide#builds

I made a commit in a branch (fix48), over the current master (see below) :

I have still some questions about the best practices to provide the patch.

  • what are the other steps I could do locally before pushing ?

You can run and test it locally by starting a development IDE from Eclipse. See https://github.com/eclipse-egit/egit/wiki/Contributor-Guide#running-egit-from-eclipse

  • Is that ok to push it directly from eclipse ?

yes, first configure Gerrit for this repo following https://github.com/eclipse-egit/egit/wiki/User-Guide#working-with-gerrit
Then select the repo in the repositories view and click "Push to Gerrit..."

  • Is there still a 'Gerrit' plugin to install in Eclipse to manage changes (I used that some years ago...)...

There is some Gerrit integration included in EGit which you can enable as described above

If Eclipse doesn't have credentials for GerritHub it will open a login dialog where you should enter your GitHub username and personal access token in the password field.

  • how can I bind my change to the corresponding issue in the comment ? Is it 'Fix-48' ? (there is no template for that in the default commit message).

add a "Bug: egit-<issue id>" commit message trailer in the last paragraph of the commit message as explained in https://github.com/eclipse-egit/egit/wiki/Contributor-Guide#commit-message-guidelines

Other things :

  • I didn't add the 'file header' voluntary to see if the review will reject my change

I don't understand what you mean by file header

  • I didn't add tests also to see if the review will reject it

Sorry to ask these simple questions but I am trying to find the easiest ways to contribute on Eclipse in general and to take the role of a real newbie (which I am actually on this project :)) ...