-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit-msg
executable file
·32 lines (27 loc) · 1.12 KB
/
commit-msg
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
#!/bin/sh
#
# commit-msg.sh
#
# Removes Comment Markers around the meta information generated by
# the prepare-commit-msg git hook
#
# To enable this hook, rename this file to "commit-msg".
# commit-msg
# This hook is invoked by git-commit[1] and git-merge[1], and can be bypassed with the --no-verify option. It takes a single parameter, the name of the file that holds the proposed commit log message. Exiting with a non-zero status causes the command to abort.
# The hook is allowed to edit the message file in place, and can be used to normalize the message into some project standard format. It can also be used to refuse the commit after inspecting the message file.
# The default commit-msg hook, when enabled, detects duplicate "Signed-off-by" lines, and aborts the commit if one is found.
get_clean_message() {
egrep -o '^[[:space:]]*$|^ *#' "$1"
}
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$TEXT" ]
then
[ -z "$(get_clean_message "$1")" ] && {
echo >&2 Commit message cannot be empty.
exit 1
}
echo "$(cat "$1" | perl -p -e 's/#!()/$1/')" > "$1"
else
echo "Aborting commit due to empty commit message."
exit 1
fi