-
-
Notifications
You must be signed in to change notification settings - Fork 415
Expand file tree
/
Copy pathcommit-msg
More file actions
32 lines (29 loc) · 2 KB
/
Copy pathcommit-msg
File metadata and controls
32 lines (29 loc) · 2 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
#!/bin/bash
# set all strings to UTF-8
LC_CTYPE=en_US.utf8
# Pre-check: if it looks like a public release note (starts with "+ (Domain)")
# but is missing the required verb, catch it early with a clear message.
if echo "$1" | grep -qP '^\+\s+\(\w[\w\s]*\)\s+(?!Add|Fix|Improv|Updat)'; then
echo "ERROR: Public release notes must start with Add, Fix, Improve, or Update after the domain tag." >&2
echo "" >&2
echo " See commit guidelines: https://community.rockrms.com/developer/developer-codex/coding-standards/committing-code" >&2
exit 1
fi
# regex to validate the commit message against
# The domains come from the official "Rock Domain" list at https://admin.sparkdevnetwork.org/admin/general/defined-types
commit_regex='(^([+]{1}[ ]{1}(\(AI\)|\(Apple TV\)|\(API\)|\(CMS\)|\(Check\-in\)|\(Communication\)|\(Connection\)|\(Core\)|\(CRM\)|\(Engagement\)|\(Event\)|\(Farm\)|\(Finance\)|\(Group\)|\(Lava\)|\(LMS\)|\(Mobile\)|\(Prayer\)|\(Reminders\)|\(Reporting\)|\(Security\)|\(Workflow\)|\(Other\)){1}[ ]{1}(Add*|Fix*|Improv*|Updat*){1}[\s\S][^\n]+(\. (\(Fix(?:es|ed) #\d+(?:\s*,\s*(?:Fix(?:es|ed)\s*)?#\d+)*\))$|[\w]\.$){1})|^([-]{1}[ ]{1}[\s\S][^\n]+)){1}|^(Merge+.+)|^(Revert+.+)|^(Cherry+.+)'
error_message_1="Your commit message should be a single-line and in one of the following formats:"
error_message_2a=" [Github Issue/PR Fix]: + (Domain) Add/Fix/Improve/Update Text. (Fixes #0000)"
error_message_2b=" + (Domain) Add/Fix/Improve/Update Text. (Fixes #0000, Fixes #1234)"
error_message_3=" [Public release note]: + (Domain) Add/Fix/Improve/Update Text."
error_message_4=" [Internal commit msg]: - Text"
guide_link=" See commit guidelines: https://community.rockrms.com/developer/developer-codex/coding-standards/committing-code"
if ! grep -r -n -H -P "$commit_regex" "$1"; then
echo "${error_message_1}" >&2
echo "${error_message_2a}" >&2
echo "${error_message_2b}" >&2
echo "${error_message_3}" >&2
echo "${error_message_4}" >&2
echo "${guide_link}" >&2
exit 1
fi