diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-02 22:10:06 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-02 22:10:21 +0200 |
commit | 4f7f2d4a4a0d65117de0fceb022775bc8fd61f10 (patch) | |
tree | 8ea869baa473c38c984417e61e5947f055cf9f29 /githooks | |
parent | 7c5cbc6a4d67184d3534f6a10dab3b1334ac7d8d (diff) | |
download | deployment-4f7f2d4a4a0d65117de0fceb022775bc8fd61f10.tar.gz deployment-4f7f2d4a4a0d65117de0fceb022775bc8fd61f10.tar.bz2 deployment-4f7f2d4a4a0d65117de0fceb022775bc8fd61f10.zip |
git hook
Diffstat (limited to 'githooks')
-rw-r--r-- | githooks/update | 32 |
1 files changed, 32 insertions, 0 deletions
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 |