aboutsummaryrefslogtreecommitdiff
path: root/contrib/conf/commit-msg
blob: daa5262701836bb9ea52a2476e66d2f6d0bd47df (plain) (blame)
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
#!/bin/bash

# use as .git/hooks/commit-msg

COMMIT_MSG_FILE=$1

exec 1>&2

RET=0
changed=$(git diff --cached --name-only)

for f in $changed;
do
 # Only headers in include
 if echo $f | grep \src\/include\/.\*\.h\$  > /dev/null
 then
   RET=1
   # Check if it has a ChangeLog line
   if cat $COMMIT_MSG_FILE | grep \^ChangeLog: > /dev/null
   then
       RET=0
       break
   fi
 fi
done

# If no ChangeLog line found, abort
if [ $RET = 1 ];
then
  echo "Your commit includes staged changes that indicate an API change which requires a ChangeLog line."
else
  echo "Your commit does not include API changes"
fi
exit $RET