Last active
July 31, 2017 16:22
-
-
Save wookietreiber/abad73d1c1811a1fed4a7019b34e9c5f to your computer and use it in GitHub Desktop.
git hook delegate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GIT_HOOK_DIR="$0.d" | |
if [[ -d $GIT_HOOK_DIR ]] ; then | |
while IFS= read -r -d $'\0' hook ; do | |
"./$hook" || error="yes" | |
done < <(find "$GIT_HOOK_DIR" -mindepth 1 -print0) | |
[[ -n $error ]] && exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a very simple delegate script for git hooks. The problem with git hooks is, that you can only have one per hook category, e.g. pre-commit. This delegate expects a directory, e.g. pre-commit.d and runs everything inside that directory.
Installation
To demonstrate the installation, we are going to check this repository itself using shellcheck. For this to work you will need to install shellcheck yourself using your package manager (pacman, yum, apt, ...). Once that is done: