From 53da09d924b2068904929c760ddc243b87247d20 Mon Sep 17 00:00:00 2001 From: Steffen Hiller Date: Tue, 11 Dec 2018 11:06:09 +0100 Subject: [PATCH] Add first version of block skip checks hook --- pre-receive-hooks/block_skip_checks.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 pre-receive-hooks/block_skip_checks.sh diff --git a/pre-receive-hooks/block_skip_checks.sh b/pre-receive-hooks/block_skip_checks.sh new file mode 100755 index 000000000..c54d6d4d0 --- /dev/null +++ b/pre-receive-hooks/block_skip_checks.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Check and reject commits with "skip-checks: true" trailer lines. +# +# This hook basically disables the following feature: +# https://help.github.com/articles/about-status-checks/#skipping-and-requesting-checks-for-individual-commits + +ERROR_MSG="[POLICY] Skipping checks is not allowed. Please remove trailer lines with \"skip-checks: true\"." + +while read OLDREV NEWREV REFNAME ; do + for COMMIT in `git rev-list $OLDREV..$NEWREV`; + do + MESSAGE=`git cat-file commit $COMMIT | git interpret-trailers --parse` + if echo $MESSAGE | grep -iq "skip-checks: true"; then + echo "$ERROR_MSG" >&2 + exit 1 + fi + done +done +exit 0 \ No newline at end of file