]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
patman: Support collecting response tags in Patchstream
authorSimon Glass <sjg@chromium.org>
Mon, 6 Jul 2020 03:41:57 +0000 (21:41 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 20 Jul 2020 17:37:47 +0000 (11:37 -0600)
Collect response tags such as 'Reviewed-by' while parsing the stream.
This allows us to see what tags are present.

Add a new 'Fixes' tag also, since this is now quite common.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/patman/commit.py
tools/patman/patchstream.py

index 48d0529c536520cad1fc50f103b96a6fb93abfd7..8d583c4ed393a093d2b13f006da7a3508001de60 100644 (file)
@@ -2,6 +2,7 @@
 # Copyright (c) 2011 The Chromium OS Authors.
 #
 
+import collections
 import re
 
 # Separates a tag: at the beginning of the subject from the rest of it
@@ -23,6 +24,9 @@ class Commit:
         notes: List of lines in the commit (not series) notes
         change_id: the Change-Id: tag that was stripped from this commit
             and can be used to generate the Message-Id.
+        rtags: Response tags (e.g. Reviewed-by) collected by the commit, dict:
+            key: rtag type (e.g. 'Reviewed-by')
+            value: Set of people who gave that rtag, each a name/email string
     """
     def __init__(self, hash):
         self.hash = hash
@@ -33,6 +37,7 @@ class Commit:
         self.signoff_set = set()
         self.notes = []
         self.change_id = None
+        self.rtags = collections.defaultdict(set)
 
     def AddChange(self, version, info):
         """Add a new change line to the change list for a version.
@@ -88,3 +93,12 @@ class Commit:
           return False
         self.signoff_set.add(signoff)
         return True
+
+    def AddRtag(self, rtag_type, who):
+        """Add a response tag to a commit
+
+        Args:
+            key: rtag type (e.g. 'Reviewed-by')
+            who: Person who gave that rtag, e.g. 'Fred Bloggs <fred@bloggs.org>'
+        """
+        self.rtags[rtag_type].add(who)
index 2ea8ebcc3fdfe5c3890d2839c836b40dbd630898..0c68c861569f1a9ed1f5c58d4e61f6cb88b07558 100644 (file)
@@ -37,7 +37,7 @@ re_change_id = re.compile('^Change-Id: *(.*)')
 re_commit_tag = re.compile('^Commit-([a-z-]*): *(.*)')
 
 # Commit tags that we want to collect and keep
-re_tag = re.compile('^(Tested-by|Acked-by|Reviewed-by|Patch-cc): (.*)')
+re_tag = re.compile('^(Tested-by|Acked-by|Reviewed-by|Patch-cc|Fixes): (.*)')
 
 # The start of a new commit in the git log
 re_commit = re.compile('^commit ([0-9a-f]*)$')
@@ -112,6 +112,15 @@ class PatchStream:
             self.in_section = 'commit-' + name
             self.skip_blank = False
 
+    def AddCommitRtag(self, rtag_type, who):
+        """Add a response tag to the current commit
+
+        Args:
+            key: rtag type (e.g. 'Reviewed-by')
+            who: Person who gave that rtag, e.g. 'Fred Bloggs <fred@bloggs.org>'
+        """
+        self.commit.AddRtag(rtag_type, who)
+
     def CloseCommit(self):
         """Save the current commit into our commit list, and reset our state"""
         if self.commit and self.is_log:
@@ -346,12 +355,14 @@ class PatchStream:
 
         # Detect tags in the commit message
         elif tag_match:
+            rtag_type, who = tag_match.groups()
+            self.AddCommitRtag(rtag_type, who)
             # Remove Tested-by self, since few will take much notice
-            if (tag_match.group(1) == 'Tested-by' and
-                    tag_match.group(2).find(os.getenv('USER') + '@') != -1):
+            if (rtag_type == 'Tested-by' and
+                    who.find(os.getenv('USER') + '@') != -1):
                 self.warn.append("Ignoring %s" % line)
-            elif tag_match.group(1) == 'Patch-cc':
-                self.commit.AddCc(tag_match.group(2).split(','))
+            elif rtag_type == 'Patch-cc':
+                self.commit.AddCc(who.split(','))
             else:
                 out = [line]