this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve hook handler

+68 -6
+1
git/hooks.d/style-check/pre-commit
··· 1 + #!/bin/
+67 -6
git/hooks/hook.sh
··· 1 1 #!/bin/bash 2 2 3 - script="$(basename "$0")" 4 - HOOKS_DIR="$(command git config --get core.hooksPath || echo "$GIT_DIR/hooks")" 5 - PLUGS_DIR="$HOOKS_DIR/plugs" 3 + hooks=(post-checkout post-commit post-merge pre-commit pre-push prepare-commit-msg) 4 + 5 + usage() { 6 + echo "$0 [install|help]" 7 + echo 8 + echo "Simple git hooks management system" 9 + echo 10 + } 11 + 12 + install() { 13 + source="${BASH_SOURCE[0]}" 14 + DIR="${1:-"$(git rev-parse --show-toplevel)"}" 15 + HOOK_DIR="${2:-"$DIR/.git/hooks"}" 16 + 17 + echo "Install handler" 18 + echo 19 + 20 + mkdir -p "$HOOK_DIR" 21 + cp -i "$0" "$HOOK_DIR/hook.sh" 22 + 23 + echo "Installing hooks" 24 + echo 25 + 26 + for hook in "${hooks[@]}" 27 + do 28 + echo "Installing $hook" 29 + ln -si "hook.sh" "$HOOK_DIR/$hook" 30 + done 31 + } 32 + 33 + hook() { 34 + script="$(basename "$0")" 35 + PLUG_DIRS=("$(command git config --get hooks.path)" "$GIT_DIR/hooks/hooks.d") 36 + 37 + echo "## Hook $script" 38 + echo 39 + 40 + test -d "$GIT_DIR"/rebase-merge -o -d "$GIT_DIR"/rebase-apply && exit 0 6 41 7 - test -d "$GIT_DIR"/rebase-merge -o -d "$GIT_DIR"/rebase-apply && exit 0 8 - find "$PLUGS_DIR" -depth 2 -and -name "$script" -print0 | \ 9 - xargs -0 -n1 sh -c '"$1" && echo "$(basename "$(dirname "$1")"): ok"' -- 42 + for dir in "${PLUG_DIRS[@]}" 43 + do 44 + if [ -d "$dir" ] 45 + then 46 + find "$dir" -depth 2 -and -name "$script" -print0 2>/dev/null \ 47 + | xargs -t0 -n1 -I_ sh -c '[ -x "$1" ] && printf "\n###### %s\n" "$1" && "$@" && echo "ok"' -- _ "$@" 48 + 49 + if [ ! "$?" -eq 0 ] 50 + then 51 + return "$?" 52 + fi 53 + fi 54 + done 55 + } 56 + 57 + case "$1" in 58 + install) 59 + shift 60 + install 61 + exit 0 62 + ;; 63 + help) 64 + shift 65 + usage 66 + exit 67 + ;; 68 + *) 69 + hook "$@" 70 + esac
git/hooks/plugs/email/pre-commit git/hooks.d/email/pre-commit
git/hooks/plugs/trailing-whitespaces/pre-commit git/hooks.d/trailing-whitespaces/pre-commit
git/hooks/plugs/unresolved-merge/pre-commit git/hooks.d/unresolved-merge/pre-commit
git/hooks/plugs/wip-check/pre-push git/hooks.d/wip-check/pre-push