generated from rochacbruno/python-project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
commit-msg
44 lines (33 loc) · 1.24 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
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Colored text in terminal output
GREEN="\033[0;32m"
RED="\033[0;31m"
YELLOW="\033[0;33m"
NC="\033[0m"
commit_msg=$(cat "${1:?Missing commit message file}")
commit_regex='^#WS-\d+:.*$'
error_msg='
'${0}': '$RED'Aborting commit due to absent Worksection task id in commit'$NC'.
Commit message should follow pattern: "#WS-0000: The commmit message",
where "0000" is Worksection task ID.
Your commit message is "'$YELLOW${commit_msg}$NC'"
How to fix:
* Option 1 ('$GREEN'for HERO'$NC'): git amend
git commit --amend -m "#WS-???: your message"
git push
More:
> https://github.com/k88hudson/git-flight-rules#i-wrote-the-wrong-thing-in-a-commit-message
> https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
> RUS https://bit.ly/3HDF4Iq
> RUS https://www.youtube.com/watch?v=zitQtjMoHRI
> https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/changing-a-commit-message
* Option 2 ('$RED'for loosers'$NC'): Fix some minor changes (for example - add space somewhere)
git add <your recently modified file>
git commit -m "#WS-???: your message"
git push
'
if ! grep -iqE "$commit_regex" "$1"; then
echo -e "${error_msg}" >&2
exit 1
fi
exit 0