-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommit-msg
More file actions
48 lines (42 loc) · 1.59 KB
/
commit-msg
File metadata and controls
48 lines (42 loc) · 1.59 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
#test "" = "$(grep '^Signed-off-by: ' "$1" |
# sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
# echo >&2 Duplicate Signed-off-by lines.
# exit 1
#}
# Text Reset
RESET='\e[0m'
BLINK='\e[5m'
# Regular Colors
RED='\e[0;31m'
YELLOW='\e[0;33m'
GREEN='\e[0;32m'
# Append actual date and time to git commit message
sed -i.bak -e "1s/^/[`date +"%F %T"`] /" $1
# Aspell to spellcheck for commit messages.
ASPELL=$(which aspell)
if [ $? -ne 0 ]; then
echo "${RED}Aspell not installed - unable to check spelling${RESET}" >&2
exit
else
WORDS=$(${ASPELL} list < "$1")
fi
if [ -n "${WORDS}" ]; then
echo "${YELLOW}Possible spelling errors found in commit message. Use ${RESET}${GREEN}${BLINK}git commit --amend -m 'New commit message' ${RESET}${YELLOW}to change the message.${RESET}"
echo "${YELLOW}Possible mispelled words: ${RESET}${RED}" $WORDS "${RESET}" >&2
fi