1 # Copyright (c) 2011 The Chromium OS Authors.
3 # SPDX-License-Identifier: GPL-2.0+
8 # Separates a tag: at the beginning of the subject from the rest of it
9 re_subject_tag = re.compile('([^:\s]*):\s*(.*)')
12 """Holds information about a single commit/patch in the series.
15 hash: Commit hash (as a string)
20 tags: List of maintainer tag strings
21 changes: Dict containing a list of changes (single line strings).
22 The dict is indexed by change version (an integer)
23 cc_list: List of people to aliases/emails to cc on this commit
24 notes: List of lines in the commit (not series) notes
26 def __init__(self, hash):
32 self.signoff_set = set()
35 def AddChange(self, version, info):
36 """Add a new change line to the change list for a version.
39 version: Patch set version (integer: 1, 2, 3)
40 info: Description of change in this version
42 if not self.changes.get(version):
43 self.changes[version] = []
44 self.changes[version].append(info)
47 """Create a list of subject tags in the commit
49 Subject tags look like this:
51 propounder: fort: Change the widget to propound correctly
53 Here the tags are propounder and fort. Multiple tags are supported.
54 The list is updated in self.tag.
57 None if ok, else the name of a tag with no email alias
62 m = re_subject_tag.match(str)
69 def AddCc(self, cc_list):
70 """Add a list of people to Cc when we send this patch.
73 cc_list: List of aliases or email addresses
75 self.cc_list += cc_list
77 def CheckDuplicateSignoff(self, signoff):
78 """Check a list of signoffs we have send for this patch
83 True if this signoff is new, False if we have already seen it.
85 if signoff in self.signoff_set:
87 self.signoff_set.add(signoff)