patman: Support collecting response tags in Patchstream
[u-boot.git] / tools / patman / commit.py
index 900cfb3a5a6c630e3894db6004b3e77a2b955fd8..8d583c4ed393a093d2b13f006da7a3508001de60 100644 (file)
@@ -1,8 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2011 The Chromium OS Authors.
 #
-# SPDX-License-Identifier:     GPL-2.0+
-#
 
+import collections
 import re
 
 # Separates a tag: at the beginning of the subject from the rest of it
@@ -21,6 +21,12 @@ class Commit:
         changes: Dict containing a list of changes (single line strings).
             The dict is indexed by change version (an integer)
         cc_list: List of people to aliases/emails to cc on this 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
@@ -28,6 +34,10 @@ class Commit:
         self.tags = []
         self.changes = {}
         self.cc_list = []
+        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.
@@ -70,3 +80,25 @@ class Commit:
             cc_list:    List of aliases or email addresses
         """
         self.cc_list += cc_list
+
+    def CheckDuplicateSignoff(self, signoff):
+        """Check a list of signoffs we have send for this patch
+
+        Args:
+            signoff:    Signoff line
+        Returns:
+            True if this signoff is new, False if we have already seen it.
+        """
+        if signoff in self.signoff_set:
+          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)
This page took 0.031288 seconds and 4 git commands to generate.