diff options
author | Kate Ward <kate.ward@forestent.com> | 2020-04-10 15:17:35 +0200 |
---|---|---|
committer | Kate Ward <kate.ward@forestent.com> | 2020-04-10 15:17:35 +0200 |
commit | 2523169c1a297331a400e548edec32fa891c1bed (patch) | |
tree | 3b6337f73d44cbfaeb4be41da066256726a105e2 /.githooks | |
parent | 77a6d9e2425071609c843751f83b2eaca5c9a06a (diff) | |
download | shflags-2523169c1a297331a400e548edec32fa891c1bed.tar.gz |
Fixes to hooks.
Diffstat (limited to '.githooks')
-rwxr-xr-x | .githooks/generic | 28 | ||||
-rwxr-xr-x | .githooks/pre-commit | 13 | ||||
-rwxr-xr-x | .githooks/pre-commit.shellcheck | 2 |
3 files changed, 29 insertions, 14 deletions
diff --git a/.githooks/generic b/.githooks/generic new file mode 100755 index 0000000..b5f3e4c --- /dev/null +++ b/.githooks/generic @@ -0,0 +1,28 @@ +#!/bin/sh +# +# A generic git hook proxy. +# https://git-scm.com/docs/githooks + +run() { + hook=$1 + file=$2 + + n=$(echo "${file}" |sed "s/^.*${hook}\.//") + echo "running ${n} ${hook}" + ${file} +} + +# Redirect output to stderr. +exec 1>&2 + +githooks='.githooks' +basename=$(basename "$0") + +for f in $(cd ${githooks} && echo *); do + case "${f}" in + pre-commit.*) + # Called by "git commit" with no arguments. + [ "${basename}" = 'pre-commit' ] && run pre-commit "${githooks}/${f}" + ;; + esac +done diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index 5ee533a..0000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# A hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. - -# Redirect output to stderr. -exec 1>&2 - -for f in .githooks/pre-commit.*; do - n=$(echo "${f}" |sed 's/^.*pre-commit\.//') - echo "running ${n} pre-commit" - $(${f}) -done diff --git a/.githooks/pre-commit.shellcheck b/.githooks/pre-commit.shellcheck index d8f364e..034f7b9 100755 --- a/.githooks/pre-commit.shellcheck +++ b/.githooks/pre-commit.shellcheck @@ -12,7 +12,7 @@ if ! command -v shellcheck >/dev/null; then return 0 fi -for f in $(git diff --name-only); do +for f in $(git diff --cached --name-only); do case "${f}" in shflags|shflags_test_helpers) shellcheck -s sh "${f}" ;; *.sh) shellcheck "${f}" ;; |