aboutsummaryrefslogtreecommitdiff
path: root/contrib/conf/prepare-commit-msg
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/conf/prepare-commit-msg')
-rwxr-xr-xcontrib/conf/prepare-commit-msg37
1 files changed, 37 insertions, 0 deletions
diff --git a/contrib/conf/prepare-commit-msg b/contrib/conf/prepare-commit-msg
new file mode 100755
index 000000000..a95f29430
--- /dev/null
+++ b/contrib/conf/prepare-commit-msg
@@ -0,0 +1,37 @@
1#!/bin/bash
2
3# use as .git/hooks/pre-commit
4
5COMMIT_MSG_FILE=$1
6COMMIT_SOURCE=$2
7SHA1=$3
8
9exec 1>&2
10
11RET=0
12changed=$(git diff --cached --name-only)
13
14for f in $changed;
15do
16 # Only headers in include
17 if echo $f | grep \src\/include\/.\*\.h\$ > /dev/null
18 then
19 RET=1
20 fi
21done
22
23# Only add custom message when there is no commit source
24# ($COMMIT_SOURCE is empty). Otherwise, keep the default message
25# proposed by Git. Possible commit source: message, template,
26# merge, squash or commit.
27if [ -z "$COMMIT_SOURCE" ];
28then
29 hint=$(cat "$COMMIT_MSG_FILE")
30 echo -e "# Our commit subject format policy is:\n# <subsystem>: <description>\n# Adding 'Issue #1234'/'Fixes #1234' into the description will automatically update/resolve issue #1234 in mantis." > "$COMMIT_MSG_FILE"
31 if [ $RET = 1 ];
32 then
33 echo -e "# Your commit includes staged changes that indicate an API change which requires a NEWS line." >> "$COMMIT_MSG_FILE"
34 fi
35 echo "$hint" >> "$COMMIT_MSG_FILE"
36fi
37exit 0