ticketfrei3/git-hooks/update

37 lines
706 B
Plaintext
Raw Permalink Normal View History

2020-07-05 21:46:55 +00:00
#!/bin/sh
#
# Copyright (C) 2020 by Thomas Lindner <tom@dl6tom.de>
#
# SPDX-License-Identifier: 0BSD
#
# server-side git-hook - checks branch policy
refname="$1"
oldrev="$2"
newrev="$3"
forbid_merge_commmits() {
if [ "$(git log --merges "$oldrev..$newrev")" ]; then
echo "merge commmits not allowed" >&2
exit 1
fi
}
only_ff_to() {
ff_branch="$1"
git rev-list "$oldrev..$ff_branch" | fgrep -x "$newrev" > /dev/null
if [ $? -ne 0 ]; then
echo "only fast-forward to $ff_branch allowed" >&2
exit 1
fi
}
case "$refname" in
refs/heads/master)
only_ff_to development
;;
refs/heads/*)
forbid_merge_commits
;;
esac