]> git.ozlabs.org Git - next-scripts/commitdiff
check_fixes: consolidate matching
authorStephen Rothwell <sfr@canb.auug.org.au>
Mon, 28 Jan 2019 00:25:45 +0000 (11:25 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 28 Jan 2019 00:25:45 +0000 (11:25 +1100)
check_fixes

index 593b735f3c9a0ded903b3070d8811c1f799949a9..34576ce0b96e73b20c8295785ae7d7f3c58465be 100755 (executable)
@@ -12,9 +12,8 @@ fi
 
 # This should be a git tree that contains *only* Linus' tree
 Linus_tree="${HOME}/kernels/linus.git"
-split_re1='^([[:xdigit:]]{5,})[[:space:]]+(.*)$'
-split_re2='^([[:xdigit:]]{5,})[[:space:]]*(.*)$'
-split_re3='^([Cc][Oo][Mm][Mm][Ii][Tt])[[:space:]]*([[:xdigit:]]{5,})[[:space:]]*(.*)$'
+
+split_re='^([Cc][Oo][Mm][Mm][Ii][Tt])?[[:space:]]*([[:xdigit:]]{5,})([[:space:]]*)(.*)$'
 nl=$'\n'
 
 # Strip the leading and training spaces from a string
@@ -49,24 +48,20 @@ has these problem(s):
                sha=
                subject=
                msg=
-               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]}"
-                       msg="${msg:+${msg}${nl}}  - "
+               if [[ "$f" =~ $split_re ]]; then
+                       first="${BASH_REMATCH[1]}"
+                       sha="${BASH_REMATCH[2]}"
+                       spaces="${BASH_REMATCH[3]}"
+                       subject="${BASH_REMATCH[4]}"
+                       if [ "$first" ]; then
+                               msg="${msg:+${msg}${nl}}  - leading word '$first' unexpected"
+                       fi
                        if [ -z "$subject" ]; then
-                               msg+="missing subject"
-                       else
-                               msg+="missing space between the SHA1 and the subject"
+                               msg="${msg:+${msg}${nl}}  - missing subject"
+                       elif [ -z "$spaces" ]; then
+                               msg="${msg:+${msg}${nl}}  - 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
+               else
                        printf '%s%s  - %s\n' "$commit_msg" "$fixes_msg" 'No SHA1 recognised'
                        commit_msg=''
                        continue