Validate the bug ID format in Kokoro presubmit

Previously any line starting with Bug: was accepted.
This change restricts it to Buganizer and Monorail bugs of the form:
Bug: b/141892461
Bug: swiftshader:123

Note nothing else is accepted before or after this match (including
whitespace). Multiple bug references must go on separate lines.

This ensures the bug ID is recognized correctly by Buganizer,
Monorail, and Gerrit tools that parse them out.

Bug: b/141892461
Change-Id: I910b18eba1a2bb473f2713c088c408cb31867487
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39910
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/tests/presubmit.sh b/tests/presubmit.sh
index 99db52b..87ac54c 100755
--- a/tests/presubmit.sh
+++ b/tests/presubmit.sh
@@ -40,11 +40,13 @@
 
 # Validate commit message
 function run_bug_in_commit_msg() {
-  git log -1 --pretty=%B | grep -E '^Bug:|^Issue:|^Fixes:|^Regres:'
+  git log -1 --pretty=%B | grep -E '^(Bug|Issue|Fixes):(\s?)((b\/)|(\w+:))([0-9]+)$|(^Regres:)'
 
   if [ $? -ne 0 ]
   then
-    echo "Git commit message must have a Bug: line."
+    echo "Git commit message must have a Bug: line"
+    echo "followed by a bug ID in the form b/# for Buganizer bugs or"
+    echo "project:# for Monorail bugs (e.g. 'Bug: chromium:123')."
     return 1
   fi
 }
@@ -92,4 +94,4 @@
 check gofmt run_gofmt
 
 echo
-echo "${green}All check completed successfully.$normal"
\ No newline at end of file
+echo "${green}All check completed successfully.$normal"