patman: Avoid duplicate sign-offs
authorSimon Glass <sjg@chromium.org>
Sun, 20 Apr 2014 16:50:14 +0000 (10:50 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 9 May 2014 20:50:45 +0000 (14:50 -0600)
Keep track of all Signed-off-by tags in a commit and silently suppress any
duplicates.

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

index b3aba136b86f66e65db4bd3dbebe6f0fe7b851f1..5fb508b80df10d3b11d95eea95a141ce3d0ef578 100644 (file)
@@ -192,6 +192,7 @@ END
        A sign-off is added automatically to your patches (this is
        probably a bug). If you put this tag in your patches, it will
        override the default signoff that patman automatically adds.
+       Multiple duplicate signoffs will be removed.
 
  Tested-by: Their Name <email>
  Reviewed-by: Their Name <email>
index 89cce7f88a297dd32e486cd3cd1a7a0ef7819332..3e0adb8f7e292afb8986dafc1d9d8778662855b9 100644 (file)
@@ -29,6 +29,7 @@ class Commit:
         self.tags = []
         self.changes = {}
         self.cc_list = []
+        self.signoff_set = set()
         self.notes = []
 
     def AddChange(self, version, info):
@@ -72,3 +73,16 @@ 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
index c4017e0e6d6c1f25a19b1e37cdde8535f1b7883b..9f5682cd0f50a9ba94374c9ccb88dc8bb36ea352 100644 (file)
@@ -21,7 +21,7 @@ re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Change-Id:|^Review URL:'
 re_allowed_after_test = re.compile('^Signed-off-by:')
 
 # Signoffs
-re_signoff = re.compile('^Signed-off-by:')
+re_signoff = re.compile('^Signed-off-by: *(.*)')
 
 # The start of the cover letter
 re_cover = re.compile('^Cover-letter:')
@@ -159,6 +159,7 @@ class PatchStream:
         commit_tag_match = re_commit_tag.match(line)
         commit_match = re_commit.match(line) if self.is_log else None
         cover_cc_match = re_cover_cc.match(line)
+        signoff_match = re_signoff.match(line)
         tag_match = None
         if self.state == STATE_PATCH_HEADER:
             tag_match = re_tag.match(line)
@@ -223,7 +224,7 @@ class PatchStream:
             if is_blank:
                 # Blank line ends this change list
                 self.in_change = 0
-            elif line == '---' or re_signoff.match(line):
+            elif line == '---':
                 self.in_change = 0
                 out = self.ProcessLine(line)
             else:
@@ -272,6 +273,11 @@ class PatchStream:
             else:
                 self.tags.append(line);
 
+        # Suppress duplicate signoffs
+        elif signoff_match:
+            if self.commit.CheckDuplicateSignoff(signoff_match.group(1)):
+                out = [line]
+
         # Well that means this is an ordinary line
         else:
             pos = 1