diff options
author | Tomek Mrugalski <tomasz@isc.org> | 2019-12-03 16:51:18 +0100 |
---|---|---|
committer | Tomek Mrugalski <tomasz@isc.org> | 2019-12-13 18:38:25 +0100 |
commit | 1157db4698a6ef802df18743493c810b2df98756 (patch) | |
tree | 840c05d5a98e3a6131a0d43d242364e2b6f84695 /tools | |
parent | [#1041] Added ChangeLog for #1041. (diff) | |
download | kea-1157db4698a6ef802df18743493c810b2df98756.tar.xz kea-1157db4698a6ef802df18743493c810b2df98756.zip |
[#1042] prepare-commit-msg hooks added
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/git-hooks-install | 23 | ||||
-rwxr-xr-x | tools/git-hooks/prepare-commit-msg | 15 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tools/git-hooks-install b/tools/git-hooks-install new file mode 100755 index 0000000000..be885931db --- /dev/null +++ b/tools/git-hooks-install @@ -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 diff --git a/tools/git-hooks/prepare-commit-msg b/tools/git-hooks/prepare-commit-msg new file mode 100755 index 0000000000..13bbe84a72 --- /dev/null +++ b/tools/git-hooks/prepare-commit-msg @@ -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" |