2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-22 01:49:48 +00:00

[#1042] prepare-commit-msg hooks added

This commit is contained in:
Tomek Mrugalski 2019-12-03 16:51:18 +01:00
parent 6e9f507871
commit 1157db4698
2 changed files with 38 additions and 0 deletions

23
tools/git-hooks-install Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
# This script install user-side git commit hooks. You are supposed to run it
# only once for each repo (and very infrequently afterwards, once each time
# the git hooks change).
if test -d .git; then
TOPDIR=.
else
TOPDIR=..
fi
GITDIR=${TOPDIR}/.git
if test ! -d ${GITDIR}; then
echo "ERROR: Could not find ${GITDIR} in ${TOPDIR}"
exit -1
fi
echo "Installing hooks in ${GITDIR}/hooks"
mkdir -p ${GITDIR}/hooks
cp ${TOPDIR}/tools/git-hooks/prepare-commit-msg ${GITDIR}/hooks
chmod u+x ${GITDIR}/hooks/prepare-commit-msg

View File

@ -0,0 +1,15 @@
#!/bin/sh
BRANCH=`git branch | grep '^\*' | cut -b3-`
if test "$BRANCH" == "master"; then
echo "ERROR: You are on branch $BRANCH"
echo "ERROR: You are not allowed to commit to master directly. Please follow the process"
echo "ERROR: (create issue, then MR for it, ...)"
exit 1
fi
BRANCH_NUMBER=`git branch | grep -o '^\* [0-9]*' | cut -b3-`
/bin/echo -n "[#$BRANCH_NUMBER] " > "$1.msg"
cat "$1" >> "$1.msg"
mv "$1.msg" "$1"