contrib/gen_uprev_msg.py: Ignore commits by bot

Commits by chrome-bot or chromeos-ci-release such as

- Marking set of ebuilds as stable
- Incremented to version: 13885.38.0
- Increment to version R91-13885.37.0-1

are not that important for firmware change log, so ignore them from the
script.

BUG=none
TEST=./gen_uprev_msg.py

Change-Id: I57826316b746c95366b26de3004d424e80ce77ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2939074
Tested-by: Yu-Ping Wu <yupingso@chromium.org>
Auto-Submit: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-by: Chen-Tsung Hsieh <chentsung@chromium.org>
Commit-Queue: Chen-Tsung Hsieh <chentsung@chromium.org>
diff --git a/contrib/gen_uprev_msg.py b/contrib/gen_uprev_msg.py
index fbb6d5b..6718729 100755
--- a/contrib/gen_uprev_msg.py
+++ b/contrib/gen_uprev_msg.py
@@ -26,6 +26,12 @@
 MAX_LENGTH = 72
 CHANGES_PATTERN = r'Changes between ([0-9\.]+) and ([0-9\.]+)'
 
+IGNORED_PATTERNS = (
+    'Marking set of ebuilds as stable',
+    r'Incremented to version: \d+\.\d+\.\d+',
+    r'Increment to version R\d+-\d+\.\d+\.\d+.*',
+)
+
 DEFAULT_REPOS = (
     'src/overlays',
     'src/platform/bmpblk',
@@ -94,6 +100,7 @@
     repos = []
     repo = None
     ignored_repos = []
+    ignored_commits = []
     skipped_lines = []
     for line in sys.stdin:
         line = line.strip()
@@ -124,12 +131,20 @@
             continue
 
         cl = parse_cl(line)
-        if cl:
-            cl_list.append(cl)
-        else:
+        if not cl:
             skipped_lines.append(line)
             continue
 
+        ignored = False
+        for pattern in IGNORED_PATTERNS:
+            if re.fullmatch(pattern, cl.title):
+                ignored = True
+                continue
+        if ignored:
+            ignored_commits.append((cl.commit, repo))
+        else:
+            cl_list.append(cl)
+
     if not repos:
         logger.error('No repo found from ChangeLog')
         return 1
@@ -145,6 +160,8 @@
 
     bugs = set()
     for repo, cl_list in repos:
+        if not cl_list:
+            continue
         print()
         print(repo)
         private = 'private' in repo
@@ -152,6 +169,13 @@
             if cl.cl:
                 cl_str = f'CL:*{cl.cl}' if private else f'CL:{cl.cl}'
             else:
+                ignored = False
+                for pattern in IGNORED_PATTERNS:
+                    if re.fullmatch(pattern, cl.title):
+                        ignored = True
+                        continue
+                if ignored:
+                    continue
                 cl_str = 'CL:' + '?' * 7
                 print('>>>>>>> PLEASE FILL THE CL NUMBER MANUALLY')
             title = cl.title
@@ -188,6 +212,8 @@
     # Warnings
     for repo in ignored_repos:
         logger.warning('Ignore repo %s', repo)
+    for commit, repo in ignored_commits:
+        logger.warning('Ignore commit %s in %s', commit, repo)
     for line in skipped_lines:
         logger.warning('Skipping line: %s', line)