Skip to content

Commit 7aaeed1

Browse files
committed
Change 'COMMIT_MSG_LINES' to 'commit_msg_lines'
PR sysprog21#209's functionality was broken due to changes introduced in PR sysprog21#214, specifically in commit '4a8d8b5', where some occurrences of 'COMMIT_MSG_LINES' were replaced with 'commit_msg_lines' without updating all relevant functions. This commit fixes the issue by replacing all instances of 'COMMIT_MSG_LINES' with 'commit_msg_lines', ensuring consistency and restoring the functionality introduced in PR sysprog21#209. Change-Id: I0c93617be83c5f24b1e17678566883c0481ddc48
1 parent 7db0d54 commit 7aaeed1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

scripts/commit-msg.hook

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# https://github.com/tommarshall/git-good-commit
77

88
COMMIT_MSG_FILE="$1"
9-
COMMIT_MSG_LINES=
9+
commit_msg_lines=
1010
HOOK_EDITOR=
1111
SKIP_DISPLAY_WARNINGS=0
1212
WARNINGS=
@@ -69,7 +69,7 @@ display_warnings() {
6969
fi
7070

7171
for i in "${!WARNINGS[@]}"; do
72-
printf "%-74s ${WHITE}%s${NC}\n" "${COMMIT_MSG_LINES[$(($i-1))]}" "[line ${i}]"
72+
printf "%-74s ${WHITE}%s${NC}\n" "${commit_msg_lines[$(($i-1))]}" "[line ${i}]"
7373
IFS=';' read -ra WARNINGS_ARRAY <<< "${WARNINGS[$i]}"
7474
for ERROR in "${WARNINGS_ARRAY[@]}"; do
7575
echo -e " ${YELLOW}- ${ERROR}${NC}"
@@ -86,7 +86,7 @@ EOF
8686
# Read the contents of the commit msg into an array of lines.
8787
read_commit_message() {
8888
# reset commit_msg_lines
89-
COMMIT_MSG_LINES=()
89+
commit_msg_lines=()
9090

9191
# read commit message into lines array
9292
while IFS= read -r; do
@@ -98,7 +98,7 @@ read_commit_message() {
9898

9999
# ignore comments
100100
[[ $REPLY =~ ^# ]]
101-
test $? -eq 0 || COMMIT_MSG_LINES+=("$REPLY")
101+
test $? -eq 0 || commit_msg_lines+=("$REPLY")
102102

103103
[[ $REPLY =~ "# ------------------------ >8 ------------------------" ]]
104104
break
@@ -241,10 +241,10 @@ validate_commit_message() {
241241
WARNINGS=()
242242

243243
# capture the subject, and remove the 'squash! ' prefix if present
244-
COMMIT_SUBJECT=${COMMIT_MSG_LINES[0]/#squash! /}
244+
COMMIT_SUBJECT=${commit_msg_lines[0]/#squash! /}
245245

246246
# if the commit is empty there's nothing to validate, we can return here
247-
COMMIT_MSG_STR="${COMMIT_MSG_LINES[*]}"
247+
COMMIT_MSG_STR="${commit_msg_lines[*]}"
248248
test -z "${COMMIT_MSG_STR[*]// }" && return;
249249

250250
# if the commit subject starts with 'fixup! ' there's nothing to validate, we can return here
@@ -265,7 +265,7 @@ validate_commit_message() {
265265
echo "Aspell not installed - unable to check spelling"
266266
else
267267
LINE_NUMBER=1
268-
MISSPELLED_WORDS=$(echo "$COMMIT_MSG_LINES[LINE_NUMBER]" | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws)
268+
MISSPELLED_WORDS=$(echo "$commit_msg_lines[LINE_NUMBER]" | $ASPELL --lang=en --list --home-dir=scripts --personal=aspell-pws)
269269
if [ -n "$MISSPELLED_WORDS" ]; then
270270
add_warning LINE_NUMBER "Possible misspelled word(s): $MISSPELLED_WORDS"
271271
fi
@@ -274,7 +274,7 @@ validate_commit_message() {
274274
# 1. Separate subject from body with a blank line
275275
# ------------------------------------------------------------------------------
276276

277-
test ${#COMMIT_MSG_LINES[@]} -lt 1 || test -z "${COMMIT_MSG_LINES[1]}"
277+
test ${#commit_msg_lines[@]} -lt 1 || test -z "${commit_msg_lines[1]}"
278278
test $? -eq 0 || add_warning 2 "Separate subject from body with a blank line"
279279

280280
# 2. Limit the subject line to configured number of characters

0 commit comments

Comments
 (0)