diff options
Diffstat (limited to 'contrib/conf/prepare-commit-msg')
-rwxr-xr-x | contrib/conf/prepare-commit-msg | 37 |
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 | |||
5 | COMMIT_MSG_FILE=$1 | ||
6 | COMMIT_SOURCE=$2 | ||
7 | SHA1=$3 | ||
8 | |||
9 | exec 1>&2 | ||
10 | |||
11 | RET=0 | ||
12 | changed=$(git diff --cached --name-only) | ||
13 | |||
14 | for f in $changed; | ||
15 | do | ||
16 | # Only headers in include | ||
17 | if echo $f | grep \src\/include\/.\*\.h\$ > /dev/null | ||
18 | then | ||
19 | RET=1 | ||
20 | fi | ||
21 | done | ||
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. | ||
27 | if [ -z "$COMMIT_SOURCE" ]; | ||
28 | then | ||
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" | ||
36 | fi | ||
37 | exit 0 | ||