aboutsummaryrefslogtreecommitdiff
path: root/contrib/conf/commit-msg
blob: e57333c00f63840aa3c7bb20d23e94291d3e3f4d (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 NEWS line
   if cat $COMMIT_MSG_FILE | grep -i "^NEWS:\s[-,a-zA-Z][a-zA-Z]*" > /dev/null
   then
       RET=0
       break
   fi
 fi
done

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