Egit in Eclipse doesn't execute pre-commit hook - eclipse

I am trying to plug egit in Eclipse to run my pre-commit hooks. But it doesn't seem to work.
I found a similar SO Question but that doesn't seem to be working in my case.
Here is what all I got as required tools
GitForWindows in place
Pre-commit hooks configured
Works well from command line and Tortoise git as well.
As suggested from answers and comments section in the aforementioned linked question, I did add the cygpath.exe empty file in C:\Program Files\Git\bin and put this in path. Also, I verified that cygpath.exe is already available in C:\Program Files\Git\usr\bin alongside ssh.exe, bash.exe.
Again, both C:\Program Files\Git\bin and C:\Program Files\Git\usr\bin are added to System variables and user variables under Environment variables in my Windows 10.
Additional info
Eclipse Version: Photon Release (4.8.0)
Eclipse Egit : 5.x version

Hooks in EGit/JGit on Windows do not require Git for Windows to be installed (JGit implements Git in Java, it does not redirect to the command line Git).
The installation directory of cygpath.exe must be in the PATH because Cygwin is required on Windows to execute a Git hook (which is bash scripts).
In your case, the empty cygpath.exe file will cause the wrong directory to be used.
For more details see this Eclipse forum discussion or look into the JGit Java code here.
See also this blog post by Christoph Zauner with more details (note, the list of supported hooks is outdated, but the concepts are still the same).

Related

Use Egit to launch pre-commit hook

I am working in Eclipse Mars (4.5.2) with EGit (4.1.1) on Windows8.
I try to launch a pre-commit hook from within eclipse using GitForWindows.
I started the pre-commit file with: #!/bin/sh
and gave the PATH Variable GITFORWINDOWS with the path to the bin folder in which the sh.exe of my GitForWindows installation is stored (C:\Program Files\Git\bin).
If I do git commit in the GitBash, pre-commit is executed correctly, thus an error is thrown if a certain string is detected in the staged files. If I commit in Eclipse nothing happens. What am I doing wrong?
EDIT
I tried it with Cygwin as well. While it is working from the cygwin terminal (as well as from the GitInWindows terminal) it is not working from within eclipse.
I set the PATH to C:\cygwin64\bin where the sh.exe is.
Can line returns be a problem? I have LF so far.
To run hooks from with in Eclipse (Egit) you need to do the following:
Hooks are implemented as scripts which need to be executed by "/bin/sh".
But on a plain windows machine you don't have a sh.exe.
So, you need to install cygwin and add <cygwin_root>/bin to your PATH.
Make sure that during cygwin installation you also install git (because the hook scripts want to execute git commands).
Setting the PATH variable for Cygwin worked in the end. I had to restart the computer though.
It still is not working for GitForWindows. This might be due to the fact that JGit has a FS_Win32_Cygwin class which extracts the path to the sh.exe from the 'PATH' variable. Such a class might not exist for GitForWindows (yet). More information here.
The version (4.1.1) of my EGit doesn't seem to play a role.

Apply patch to fix bug in Eclipse?

I have a bug in Eclipse. When stepping through the code, when it goes to another class, the editor loses focus and I have to click again on the editor to continue debugging with the keyboard shortcuts.
I've found this thread describing the bug, and a patch to fix it. Is there any way I can apply the patch? I'm guessing it involves having the source code.
Yes you'd need to recompile the module and install it. These days with git SCM and the use of Maven project layouts and tycho plugin it can be easy to rebuild a module (compared to how it was just a few years ago).
Lets see now:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=372941
Patches:
bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
We search on google "git org.eclipse.e4.ui.workbench.renderers.swt" we end up at the URL:
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/
This can be used to checkout the 1 module to build.
Git is available for many linux distribution by default, google you ditro name and "install git" terms for best help. On windows there is https://code.google.com/p/msysgit/ and on MacOSX there is https://code.google.com/p/git-osx-installer/ all these provide a command line environment to use git. You can look at EGit/JGit plugins for Eclipse itself to also do the job. But the instruction below are for the command line method.
git clone https://git.eclipse.org/c/platform/eclipse.platform.ui.git
Now you'll want to find the tagged version of the version you are using. So you need to find it in your eclipse/plugins/** folder of the Eclipse install. The version number maybe in the filename or in the MANIFEST.MF or other *.xml file, the version number usually indicate the date of source and/or build in the number.
It may help to browse around the eclipse.org website link above for the GIT tree to find the version. This is to get the tag or version name / commit-id (like 'abc1234':
# List tags (might see it in the list)
git tag -l
# Look through history, maybe you can work on the date
git log
# Finally once you know the version you want
# checkout the exact version that goes with your eclipse install
git checkout -b mylocalbranch <tag_or_version>
Now you can use Maven to build it.
cd eclipse.platform.ui.git
mvn package
# The full-monty would be: mvn deploy (or 'mvn install')
# But I am not sure if unit and integration tests will work this easily, using
# the 'mvn package' it enough to get you the JAR you need to install in Eclipse.
Now you can look for a .jar in the build/* subdir, you can shutdown you eclipse and place this JAR into the plugins folder, ensure the version number is newer.
If it works update the bug report. Saying it worked for you.
Also consider trying to push it via the github accounts as a new change, crediting the original author.
..
DISCLAIMER: The above is the principal about how you might achieve what you want. It might take less than 5 minutes to complete. But there maybe complications and you'll need to research those (if you get any) independently.
You can also do much of the above with Eclipse itself, a 'git checkout' and a 'build Eclispe plugin module', although for me for this change it would probably take longer maybe 15 minutes (if there are no complications).

Automatically fill changelog.txt after each SVN commit in any IDE

After trying to search for some information about "Dynamic change of changelog.txt file with IDE", i found nothing that could help me to find the answer.
Imagine that I've made some changes in numerous files (PHP Environment) using Eclipse PHP or JetBrains PHPStorm 3+, and i want to commit them into svn repository. Is it possible to configure any of these IDEs to dynamically fill changelog.txt file in predefined format with informations (Date, SVN Comment, etc...) ?
Thanks in advance for any info which will point to the answer.
Not aware of any plugins that do this automatically, but you could write a script using command-line svn tools (svn utilities are installed by default on Linux; on Windows you can use CollabNet SVN or similar). You can pull the svn logs and redirect to changelog.txt in a format you desire.
You can also do this in python using pysvn module.

Is CVS with Eclipse using the command line possible?

I've been using Eclipse to do CVS checkout from within the Eclipse interface. Is it possible to do it using the command line just like any normal CVS program? When I type CVS in my command prompt now, I get the usual
cvs is not recognized as an internal or external command
but CVSing should be possible since it's part of Eclipse. Do I need to make changes to the environment vars? or what's needed
You need to install CVS to use it in a command line.
The document "Eclipse Compatibility with CVSNT and CVS 1.12.x" mentions:
The Eclipse CVS client is a Java implementation of a CVS client that does not require any other CVS client to be installed.
The advantage of this is that Eclipse CVS can be used without requiring the user to install any additional software.
See also compatibility FAQ:
1/ Does Eclipse use [WinCVS|CVS command-line client] to talk to the server?
No. Eclipse implements a CVS client in Java that talks directly to the server using the documented CVS protocol. No external CVS client is required.
2/ The command-line CVS client stores information in CVS folders. Does Eclipse do the same thing? If so, where are the folders?
Eclipse stores CVS sync information in CVS/ folders in the same way as the command-line CVS client does.
However, you rarely see these folders within Eclipse. They are marked using a Core facility called "team-private" which causes them to be hidden from view.
If you open a (non-Eclipse) file explorer you will see that these directories and their contents appear on the file system.
3/ Is Eclipse compatible with the command-line CVS client?
Eclipse Team CVS stores its meta information in a format that is compatible with the command-line CVS client. Thus you should be able to use a CVS command line client against Eclipse workspace files on disk. Please note that this support is experimental, and you may run into problems.

svn command line from eclipse

Hello is there a way to use svn command line from eclipse?
Within eclipse in my project browser i can righclick and then click team and than i have something like svn. Not sure which plugin it is. But it doesn't have button's to for example ignore files for uploading. That's why I want to to it command line. And my question is how to do it.
Ok so how can I use it from command line in windows xp?
The plugin you are probably using is Subclipse. It should have an "Add to svn:ignore" option. If not, try updating to the latest versions of Eclipse and Subclipse. In general subclipse should be enough and there is no need for the command line.
For Windows XP I recommend Tortoise SVN. It integrates with the Windows Explorer and offers you a graphical environment for all your needs. I would say that is much more stable than subclipse and very easy to use.
If you do want to use the command line tools, download and install svn-win32 from here. The command line tools could be helpful in merge and copy operations.
I should also point out that none of these methods interfere with each other. You can work with Tortoise SVN or the command line and subclipse won't be affected. All svn clients work by writing and reading from hidden directories called .svn. There is one such directory in every folder under source control. As long as the svn client software is of the same version, an svn client can write to these hidden folders and another one will be able to read from it. A problem could arise if one of the clients is updated to a version that uses a different protocol for writing to the .svn folders. In that case, older clients won't be able to read the information stored there. Upgrading them to the latest version will solve the problem.
Not sure what you're trying to do; sometimes it's better to describe the goal rather than the means you plan to do it.
Have you tried Subeclipse? It lets you use SVN inside Eclipse; it's great.
I'm not sure if you can use it from Eclipse, but nothing stops you from just using it. From cmd / xterm / whatever. It's not going to interfere with Eclipse in anyway, nor will it interfere with Subclipse (which I'm assuming is what you're using).
I'm using subclipse, and in generaly it works pretty well.
However, and I guess this is your problem, the Team Synchronization by default wants to add all files in my projects, not just the ones I add to version control. This is lame and frustrating, and apparently there's no way to turn it off. Screenshots for older versions, however, hints at the possibility of turning the "feature" off. Frustrating!
I'm not personally a fan of Subclipse - it slows the IDE a bit too much for my taste. Here is an alternative approach using External Tools and TortoiseSVN
Create a new External Tool
Call it SVN Commit
Set the Location to \bin\TortoiseProc.exe (mine is C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe)
Set the arguments to /command:commit /path:"${selected_resource_loc}"
Open the file / directory you want committed and run the external tool.
Interchange the commit in step four for additional commands. You can also add the specific tools to favorites and have them in a dropdown on the toolbar.
Additional Arguments Here
Not intended to be too presumptuous here, but I think you should look at whether Subversive or Subclipse actually solves problem in a different way than you intended. For instance, it is very much possible to ignore files and directories from being checked in, via Subclipse.
On the other hand, if you really want to hack away via the command prompt from Eclipse, you must install the Target Management project (supported for Eclipse Europa and Ganymede). Once you have that installed, you can launch a remote shell to your local machine and then type away on the command line :).
PS: I haven't used this approach ever; Subversive satisfied all my requirements of a SVN plugin in Eclipse.