Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Egit hooks do not get triggered

I have a git repo with a pre-commit hook that intentionally fails 100% of the time.

cat .git/hooks/pre-commit
> exit 1

If I try to commit through the command line, it fails as expected. However, if I commit from egit, the hook is ignored and the changes get committed.

Does egit/jgit not recognize hooks yet? Is there a workaround for this?

Thanks in advance!

like image 693
Ken Hirakawa Avatar asked Jun 03 '11 19:06

Ken Hirakawa


People also ask

Do Git hooks get committed?

The commit-msg hook takes one parameter, which again is the path to a temporary file that contains the commit message written by the developer. If this script exits non-zero, Git aborts the commit process, so you can use it to validate your project state or commit message before allowing a commit to go through.

How do I enable pre-commit hook?

Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.

How do you avoid pre-commit hooks?

Quick tip if you want to skip the pre-commit validations and quickly want to get a commit out there. To get your commit through without running that pre-commit hook, use the --no-verify option. Voila, without pre-commit hooks running!


1 Answers

(Original answer: June 2011)

MatrixFrog correctly points out to the bug 299315, which mentions those hooks aren't supported yet.

You also can explore the JGit repository, now on GitHub, which doesn't show any commit about hooks.
And you can search for 'hook' in the EGit User Guide: the notion of hook isn't mentioned either.


Update March 2015 (4 years later): as MariuszS points out in the comments, "hook" is present in JGit.

In 2015, there are works in progress to support those hooks:

  • "Introduce hook support into the FS implementations"
  • "Support for the pre-commit hook" (so not yet pre-receive hook)

Those should be in the upcoming JGit 3.7


Update Q4 2015, EGit 4.x does support hooks, as mentioned in this answer.

like image 110
VonC Avatar answered Oct 25 '22 23:10

VonC