forked from Praqma/git-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate
More file actions
30 lines (26 loc) · 719 Bytes
/
update
File metadata and controls
30 lines (26 loc) · 719 Bytes
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
#!/usr/bin/env bash
#
refname="$1"
old_revision="$2"
new_revision="$3"
# enforced custom commit message format
function check_message_format {
revisions=$(git rev-list $old_revision..$new_revision)
IFS='\n' read -ra array <<< "$revisions"
for rid in "${!array[@]}"; do
revision=${array[rid]}
message=$(git cat-file commit $revision | sed '1,/^$/d')
grepped=$(echo $message | grep -i "#[0-9]\+")
if [ -z "$grepped" ] ; then
grepped_none=$(echo $message | grep -i "#none")
if [ -n "$grepped_none" ] ; then
echo "Warning, you are committing without a ticket reference" >&1
else
echo "You have not included a ticket reference" >&2
exit 1
fi
fi
done
}
check_message_format
exit 0