blob: c1f2a72f1f72909850216abe7f84f5cb4eb731ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/bash
#
# To enable this hook, link it into .git/hooks/commit-msg like this:
# ln -s ../../Documentation/maintainers/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 [[ -n `grep -e '^\[sets' <<< "$summary"` ]] ; then
# Do not enforce usage of repoman where it makes no sense
exit 0
elif [[ -n `grep -e '^\[profiles' <<< "$summary"` ]] ; then
# Do not enforce usage of repoman where it makes no sense
exit 0
elif [[ -n `grep -e '^\[eclass' <<< "$summary"` ]] ; then
# Do not enforce usage of repoman where it makes no sense
exit 0
elif [[ -n `grep -e '^\[metadata' <<< "$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 -e '(Portage version|Package-Manager' "$FILE" >& /dev/null ; then
die 'Please use repoman to commit'
fi
exit 0
|