gitlab-shell/hooks/pre-receive.d/disable-force-push.sh#!/bin/sh
# <oldrev> <newrev> <refname>
# update a blame tree
while read oldrev newrev ref ; do
# old revision is blank - branch creation
if [ "$oldrev" = "0000000000000000000000000000000000000000" ] ||
# new revision is blank - branch deletion
[ "$newrev" = "0000000000000000000000000000000000000000" ] ;
then
# create new or delete old branch
continue;
fi
base=$(git merge-base $oldrev $newrev);
if [ "$base" != "$oldrev" ] ; then
# non fast forward merge
echo "Force pushing of $ref is forbidden";
exit 1;
fi
done
exit 0;