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'