Skip to content

Commit eed1d0d

Browse files
authored
Commit checker:fix minor bug,add lower case check (#856)
Now description is mandatory, trick with third line as ticket reference will not pass. Also added new feature: checking reference for lower case. Relates-To: OLPEDGE-1919 Signed-off-by: Yaroslav Stefinko <ext-yaroslav.stefinko@here.com>
1 parent 0cac9d1 commit eed1d0d

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

scripts/misc/commit_checker.sh

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,41 @@ do
3636
echo ""
3737
echo "ERROR: Title is ${current_line_len} length, so it's too long for title. Expect less than 50 chars !"
3838
echo ""
39+
cat commit.log
40+
echo "----------------------------------------------"
3941
echo "Please read following rules:"
4042
cat scripts/misc/commit_message_recom.txt
41-
exit 1
43+
exit 6
4244
fi
4345
if [ $line -eq 2 ] && [ ${current_line_len} -ne 1 ] ; then
4446
echo ""
4547
echo "ERROR: Second line in Commit Message is not zero length !"
4648
echo ""
49+
cat commit.log
50+
echo "----------------------------------------------"
4751
echo "Please read following rules:"
4852
cat scripts/misc/commit_message_recom.txt
49-
exit 1
53+
exit 5
5054
fi
51-
if [ $line -eq 3 ] && [ ${current_line_len} -lt 1 ] && [ -n $(cat commit.log| sed -n ${line}p | grep 'See also: ') ] && [ -n $(cat commit.log| sed -n ${line}p | grep 'Relates-To: ') ] && [ -n $(echo ${current_line_len}| grep 'Resolves: ') ] ; then
55+
if [ "$line" -eq 3 ] && ( [ "$current_line_len" -le 2 ] || [ -n "$(cat commit.log | sed -n ${line}p | grep 'See also: ')" ] || [ -n "$(cat commit.log | sed -n ${line}p | grep 'Relates-To: ')" ] || [ -n "$(cat commit.log | sed -n ${line}p | grep 'Resolves: ')" ] ) ; then
5256
echo ""
53-
echo "ERROR: No details added to commit message besides title !"
57+
echo "ERROR: No details added to commit message besides title and ticket reference!"
5458
echo ""
59+
cat commit.log
60+
echo "----------------------------------------------"
5561
echo "Please read following rules:"
5662
cat scripts/misc/commit_message_recom.txt
57-
exit 1
63+
exit 4
5864
fi
5965
if [ ${current_line_len} -gt 72 ] ; then
6066
echo ""
6167
echo "ERROR: ${current_line_len} chars in ${line}-th line is too long. Any line length must be less than 72 chars !"
6268
echo ""
69+
cat commit.log
70+
echo "----------------------------------------------"
6371
echo "Please read following rules:"
6472
cat scripts/misc/commit_message_recom.txt
65-
exit 1
73+
exit 3
6674
fi
6775
echo " ${line}-th line is ${current_line_len} chars length . OK."
6876
done
@@ -71,16 +79,28 @@ relates_to=$(cat commit.log | grep 'Relates-To: ') || true
7179
resolves=$(cat commit.log | grep 'Resolves: ') || true
7280
see=$(cat commit.log | grep 'See also: ') || true
7381

74-
echo "Reference like: ${relates_to} ${resolves} ${see} was found in commit message. OK."
75-
76-
if [[ -n ${relates_to} || -n ${resolves} || -n ${see} ]] ; then
82+
# This is verification that we have any of these possible issue references.
83+
if [ -n "${relates_to}" ] || [ -n "${resolves}"] || [ -n "${see}" ] ; then
84+
# This verification is needed for correct Jira linking in Gitlab.
85+
if [[ "$(echo ${relates_to}| cut -d":" -f2)" =~ [a-z] ]] || [[ "$(echo ${resolves}| cut -d":" -f2)" =~ [a-z] ]] || [[ "$(echo ${see}| cut -d":" -f2)" =~ [a-z] ]] ; then
86+
echo ""
87+
echo "ERROR: Commit message contains ticket or issue reference in lower case !"
88+
echo ""
89+
cat commit.log
90+
echo "----------------------------------------------"
91+
echo "Please read following rules:"
92+
cat scripts/misc/commit_message_recom.txt
93+
exit 2
94+
fi
7795
echo ""
78-
echo "Commit message contains issue reference. OK."
96+
echo "Commit message contains correct issue reference. OK."
7997
echo ""
8098
else
8199
echo ""
82100
echo "ERROR: Commit message does not contain ticket or issue reference like Relates-To: or Resolves: or See also: !"
83101
echo ""
102+
cat commit.log
103+
echo "----------------------------------------------"
84104
echo "Please read following rules:"
85105
cat scripts/misc/commit_message_recom.txt
86106
exit 1

0 commit comments

Comments
 (0)