diff options
| author | Dennis Schridde <devurandom@gmx.net> | 2011-01-29 19:09:22 +0100 |
|---|---|---|
| committer | Dennis Schridde <devurandom@gmx.net> | 2011-01-29 20:03:52 +0100 |
| commit | fe4ba90c7a80ae1cc7e3775a874410199e275943 (patch) | |
| tree | 12cf7e546b1ac662a855dec5300041e86f386ab4 /Documentation/git-hooks-commit-msg | |
| parent | 87efd9d82bdad0c37d0f1e436cc184d4fbe16ff4 (diff) | |
| download | kde-fe4ba90c7a80ae1cc7e3775a874410199e275943.tar.gz kde-fe4ba90c7a80ae1cc7e3775a874410199e275943.tar.bz2 kde-fe4ba90c7a80ae1cc7e3775a874410199e275943.zip | |
[Documentation/git-hooks-commit-msg] Add a sample git commit-msg hook, enforcing summary and usage of repoman
Diffstat (limited to 'Documentation/git-hooks-commit-msg')
| -rwxr-xr-x | Documentation/git-hooks-commit-msg | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Documentation/git-hooks-commit-msg b/Documentation/git-hooks-commit-msg new file mode 100755 index 00000000000..374b6cd7d53 --- /dev/null +++ b/Documentation/git-hooks-commit-msg @@ -0,0 +1,33 @@ +#!/bin/bash +# +# To enable this hook, link it into .git/hooks/commit-msg like this: +# ln -s ../../Documentation/git-hooks-commit-msg .git/hooks/commit-msg + +FILE=$1 + +die() { + echo "Aborting commit: $1" + echo "(Your message was saved in $FILE)" + exit 1 +} + +summary=`head -n1 "$FILE"` + +### Enforce first-line summary ### +if [[ -z `grep '^\[[^]]\+\]' <<< "$summary"` ]] ; then + die 'Summary (first line) should start with [changed path]' +fi + +### Enforce usage of repoman ### +if [[ -n `grep -e '^\[Documentation' <<< "$summary"` ]] ; then + # Do not enforce usage of repoman where it makes no sense + exit 0 +elif grep '^NO_REPOMAN' "$FILE" >& /dev/null ; then + # Allow i-know-what-i-am-doing override + sed -i -e '/^NO_REPOMAN/d' "$FILE" + exit 0 +elif ! grep '^(Portage version' "$FILE" >& /dev/null ; then + die 'Please use repoman to commit' +fi + +exit 0 |
