Use Egit to launch pre-commit hook - eclipse

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.

Related

Egit in Eclipse doesn't execute pre-commit hook

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).

Installing Maven 3.1.1 on Maverick and working with eclipse-Kepler TLM terminal plugin

I recently installed OS X 10.9 Mavericks. As it does not come with Maven pre installed, I installed Maven 3.1.1 manually. I exported maven and set its path in .bash_profile. It is accessible from command line. But it is not accessible from within eclipse TLM terminal plugin or Wicked Shell plugin.
One workaround I got is, I added same export statement in .bashrc and it is accessible now from within eclipse aforementioned terminal plugins. Is there any better solution for it? Can anybody explain how many .bash* files are there in mac and when each one is initialised ?
In order to have eclipse pick up the new addition to your PATH, you need to edit /etc/launchd.conf to set the environment variable explicitly. Environment variable substitutions such as $PATH will not work. To correct do an echo $PATH in terminal and copy what it returns. Then, add this line to the launchd.conf file and restart your machine.
setenv PATH <your echo $PATH results here>
After, all should return to normal in eclipse. Hope this helps!

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).

How to install and configure the EclipseFP Haskell plugin for Eclipse?

Can somone who has done this tell me exactly what to do? The documentation is lacking and what is there is incomplete and incorrect.
I've got the plugin installed, and told it to usethe GHC installation that I have as part of the Haskell Platform but Run As.. only shows me Run GHCi session. According to the cheat sheet, I should see Haskell Application.
Also missing are instructions for where to find the hugs executable, and the Cabal installation that the Haskell Preferences seems to suggest I should have.
Can anyone point out what I've missed?
I'm a Haskell beginner, hence trying to get Eclipse set up so I can play with it...
It seems that currently there is no way to create a non-interactive launch configuration
via GUI. However, you can do that by manually editing config files. The following instructions work with Eclipse 3.5.2, EclipseFP 2.0.2:
Make sure there exists a GHCI configuration.
Close Eclipse.
Go to directory .metadata/.plugins/org.eclipse.debug.core/launches in the root of your workspace.
There should be a file named something like "Main (project src).launch". Copy it under whatever name you wish, for instance "Run Main.launch"
Open your copied file in a text editor and replace the option --interactive with -e main.
Save the file and start eclipse. You should see the new run configuration "Run Main". When you run it, EclipseFP executes your Main.hs file, redirecting both input and output to the console view.
Also, it seems that you haven't configured cabal yet. You first need to install it (from your distribution repositories, or here if you're using Windows). Then go to Scion and Cabal preferences and point them to your cabal executable. After you click OK the compilation of Scion should start. If it gives you errors, read what packages are missing and install them via cabal install pkg-name. (I had to install happy with --global flag, and for QuickCheck I had to manually set the 2.* version). To rerun Scion compilation, restart Eclipse.

Setting up Pylint with PyDev

I have installed pylint via easy_install. I can run pylint <filename> with success. But pydev refuses to use it.
I checked "use pylint"
I configured correct path
I updated my python interpreter in eclipse to have pylit in pythonpath
I use Eclipse Galileo
I have build automatically checked
I tried cleaning whole project and no errors
What am I doing wrong?
I'm guessing you may need to mark the folder that contains your code as a source folder. You can do this under project properties.
Project->Properties->PyDev-PYTHONPATH
add relevant folders to the list of sources.
I've noticed that Pydev won't run Pylint on files with dashes (hyphens) the the filename; according to the Pydev devs, '-' is not a valid Python module name character, and it doesn't look like they intend to fix it:
http://sourceforge.net/tracker/index.php?func=detail&aid=1915426&group_id=85796&atid=577329
http://sourceforge.net/tracker/index.php?func=detail&aid=2888890&group_id=85796&atid=577332
As if nobody writes scripts in Python... Grumble grumble...
To provide an alternative solution, pylint can be used as an External Tool in Eclipse. This requires having previously installed the pylint package for a Python installation.
Remember to first have a pylintrc file somewhere where pylint can find it, failing which a "No config file found" error is printed. Typically I would touch pylintrc inside the project directory, and keep the file in version control. For reference, see pylint command-line options.
In Eclipse, select Run, External Tools, External Tools Configurations.... Click the toolbar button to create a New launch configuration. Configure as below or as desired:
Name: pylint
Location: ${system_path:pylint}
Working Directory: ${project_loc}
Arguments: --reports=n "${resource_loc}"
Remember to click inside an open file to switch focus to it before running the above external tool for it. Failing this, an error can occur.
The output of the external tool will by default be printed to the console.
Related: Setting up pep8 as an External Tool in Eclipse