Commit 102061bd8b0b174e1cf811dfd35641d8a9e4eba3

Authored by Simon Glass
1 parent 757f64a89b

patman: Avoid duplicate sign-offs

Keep track of all Signed-off-by tags in a commit and silently suppress any
duplicates.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 3 changed files with 23 additions and 2 deletions Side-by-side Diff

... ... @@ -192,6 +192,7 @@
192 192 A sign-off is added automatically to your patches (this is
193 193 probably a bug). If you put this tag in your patches, it will
194 194 override the default signoff that patman automatically adds.
  195 + Multiple duplicate signoffs will be removed.
195 196  
196 197 Tested-by: Their Name <email>
197 198 Reviewed-by: Their Name <email>
tools/patman/commit.py
... ... @@ -29,6 +29,7 @@
29 29 self.tags = []
30 30 self.changes = {}
31 31 self.cc_list = []
  32 + self.signoff_set = set()
32 33 self.notes = []
33 34  
34 35 def AddChange(self, version, info):
... ... @@ -72,4 +73,17 @@
72 73 cc_list: List of aliases or email addresses
73 74 """
74 75 self.cc_list += cc_list
  76 +
  77 + def CheckDuplicateSignoff(self, signoff):
  78 + """Check a list of signoffs we have send for this patch
  79 +
  80 + Args:
  81 + signoff: Signoff line
  82 + Returns:
  83 + True if this signoff is new, False if we have already seen it.
  84 + """
  85 + if signoff in self.signoff_set:
  86 + return False
  87 + self.signoff_set.add(signoff)
  88 + return True
tools/patman/patchstream.py
... ... @@ -21,7 +21,7 @@
21 21 re_allowed_after_test = re.compile('^Signed-off-by:')
22 22  
23 23 # Signoffs
24   -re_signoff = re.compile('^Signed-off-by:')
  24 +re_signoff = re.compile('^Signed-off-by: *(.*)')
25 25  
26 26 # The start of the cover letter
27 27 re_cover = re.compile('^Cover-letter:')
... ... @@ -159,6 +159,7 @@
159 159 commit_tag_match = re_commit_tag.match(line)
160 160 commit_match = re_commit.match(line) if self.is_log else None
161 161 cover_cc_match = re_cover_cc.match(line)
  162 + signoff_match = re_signoff.match(line)
162 163 tag_match = None
163 164 if self.state == STATE_PATCH_HEADER:
164 165 tag_match = re_tag.match(line)
... ... @@ -223,7 +224,7 @@
223 224 if is_blank:
224 225 # Blank line ends this change list
225 226 self.in_change = 0
226   - elif line == '---' or re_signoff.match(line):
  227 + elif line == '---':
227 228 self.in_change = 0
228 229 out = self.ProcessLine(line)
229 230 else:
... ... @@ -271,6 +272,11 @@
271 272 self.commit.AddCc(tag_match.group(2).split(','))
272 273 else:
273 274 self.tags.append(line);
  275 +
  276 + # Suppress duplicate signoffs
  277 + elif signoff_match:
  278 + if self.commit.CheckDuplicateSignoff(signoff_match.group(1)):
  279 + out = [line]
274 280  
275 281 # Well that means this is an ordinary line
276 282 else: