findmissing: Fixed bug with getting upstream sha

Regex findall method returns list of sha's, in which we only care about
the latest one.

Also added printing linux_stable insertions.

BUG=None
TEST=tested new method against commit messages

Change-Id: I43b4968faae8923aa38b2cc991b18a34b2a9e5a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2137979
Tested-by: Hirthanan Subenderan <hirthanan@google.com>
Commit-Queue: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Curtis Malainey <cujomalainey@chromium.org>
diff --git a/contrib/findmissing/common.py b/contrib/findmissing/common.py
index 407a736..4ae5513 100755
--- a/contrib/findmissing/common.py
+++ b/contrib/findmissing/common.py
@@ -102,15 +102,15 @@
                                         encoding='utf-8', errors='ignore')
 
     # "commit" is sometimes seen multiple times, such as with commit 6093aabdd0ee
-    m = re.findall(r'cherry picked from (commit )+([0-9a-f]+)', desc, re.M)
+    m = re.findall(r'cherry picked from (?:commit )+([0-9a-f]+)', desc, re.M)
     if not m:
-        m = re.findall(r'^\s*(commit )+([a-f0-9]+) upstream', desc, re.M)
+        m = re.findall(r'^\s*(?:commit )+([a-f0-9]+) upstream', desc, re.M)
         if not m:
-            m = re.findall(r'^\s*\[\s*Upstream (commit )+([0-9a-f]+)\s*\]', desc, re.M)
+            m = re.findall(r'^\s*\[\s*Upstream (?:commit )+([0-9a-f]+)\s*\]', desc, re.M)
     if m:
-        # The patch may have been picked multiple times; only record the first entry.
-        usha = m.group(2)[:12]
-        return usha
+        # The patch may have been picked multiple times; only record the last entry.
+        usha = m[-1]
+        return usha[:12]
     return usha