From 4f7f2d4a4a0d65117de0fceb022775bc8fd61f10 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 2 Oct 2016 22:10:06 +0200 Subject: git hook --- githooks/update | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 githooks/update (limited to 'githooks') diff --git a/githooks/update b/githooks/update new file mode 100644 index 0000000..47934c7 --- /dev/null +++ b/githooks/update @@ -0,0 +1,32 @@ +#!/bin/bash + +set -ue + +refname="$1" +oldrev="$2" +newrev="$3" + +if [ -z "${1+x}" ] || [ -z "${2+x}" ] || [ -z "${3+x}" ]; then + echo "Usage: $0 REFNAME OLDREV NEWREF" + exit 1 +fi + + +[[ -z "$(git rev-list --max-count 1 "$oldrev".."$newrev" || echo "fail")" ]] +is_ff=$? + +if $is_ff; then + # always allow fast forwards + exit 0 +fi + +if [[ "$refname" != refs/heads/master ]]; then + # allow force-pushing if it's not master + exit 0 +fi + +case $USER in +*) + exit 1 + ;; +esac -- cgit v1.2.3