-
Notifications
You must be signed in to change notification settings - Fork 86
gitx appears to ignore pre-commit hook when git configured for a different core.hooksPath #228
Description
Am using gitx built from the latest commit on the master branch: d0bddcc47
I setup a git pre-commit hook to check for occurrences of debugger statements in javascript.
When this pre-commit hook is located in the default location: .git/hooks/pre-commit it runs properly in both gitx and the git cli.
I wanted to keep track of the git hooks in a directory managed by git so I moved the pre-commit hook here: .githooks/pre-commit.
I then set the git configuration to use that new directory:
$ git config core.hooksPath .githooksThe pre-commit hook is run correctly when using the git cli.
However no warning is now displayed when committing a javascript file with a debugger statement using gitx.
Am not yet sure if this is a bug in gitx or one of the libraries it pulls in.
Any tips on where to look for this bug are welcome.
The repo where this occurs: https://github.com/stepheneb/cfa-own-electron (this is a large repo). If helpful I can create a minimal repo to demonstrate the issue.
file: .githooks/pre-commit
#!/bin/sh
FILES='(js)'
FORBIDDEN='(debugger)'
GREP_COLOR='4;5;37;41'
if [[ $(git diff --cached --name-only | grep -E $FILES) ]]; then
git diff --cached --name-only | grep -E $FILES | \
xargs grep --color --with-filename -n -E $FORBIDDEN && \
printf "\nLooks like you are trying to commit something you shouldn't. Please fix your diff, or run 'git commit --no-verify' to skip this check, if you must." && \
exit 1
fi
exit 0