From a3ef99805ca99d3ddfa5548e679d507fad16a7a0 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 28 Jan 2019 10:06:43 +1100 Subject: [PATCH] check_fixes: catch empty subjects --- check_fixes | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/check_fixes b/check_fixes index 29a204d..593b735 100755 --- a/check_fixes +++ b/check_fixes @@ -49,20 +49,22 @@ has these problem(s): sha= subject= msg= - [[ "$f" =~ $split_re1 ]] - sha="${BASH_REMATCH[1]}" - subject="${BASH_REMATCH[2]}" - - if [ -z "$sha" ]; then - [[ "$f" =~ $split_re2 ]] + if [[ "$f" =~ $split_re1 ]]; then + sha="${BASH_REMATCH[1]}" + subject="${BASH_REMATCH[2]}" + elif [[ "$f" =~ $split_re2 ]]; then sha="${BASH_REMATCH[1]}" subject="${BASH_REMATCH[2]}" - if [ -z "$sha" ]; then - [[ "$f" =~ $split_re3 ]] - sha="${BASH_REMATCH[2]}" - subject="${BASH_REMATCH[3]}" - msg="${msg:+${msg}${nl}} - leading word '${BASH_REMATCH[1]}' unexpected" + msg="${msg:+${msg}${nl}} - " + if [ -z "$subject" ]; then + msg+="missing subject" + else + msg+="missing space between the SHA1 and the subject" fi + elif [[ "$f" =~ $split_re3 ]]; then + sha="${BASH_REMATCH[2]}" + subject="${BASH_REMATCH[3]}" + msg="${msg:+${msg}${nl}} - leading word '${BASH_REMATCH[1]}' unexpected" fi if [ -z "$sha" ]; then printf '%s%s - %s\n' "$commit_msg" "$fixes_msg" 'No SHA1 recognised' -- 2.39.2