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:
parent
6e9f507871
commit
1157db4698
23
tools/git-hooks-install
Executable file
23
tools/git-hooks-install
Executable 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
|
15
tools/git-hooks/prepare-commit-msg
Executable file
15
tools/git-hooks/prepare-commit-msg
Executable 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"
|
Loading…
x
Reference in New Issue
Block a user