Commit 1157db46 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[#1042] prepare-commit-msg hooks added

parent 6e9f5078
#!/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
#!/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"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment