1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2011 The Chromium OS Authors.
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
25 change_id: the Change-Id: tag that was stripped from this commit
26 and can be used to generate the Message-Id.
27 rtags: Response tags (e.g. Reviewed-by) collected by the commit, dict:
28 key: rtag type (e.g. 'Reviewed-by')
29 value: Set of people who gave that rtag, each a name/email string
30 warn: List of warnings for this commit, each a str
31 patch (str): Filename of the patch file for this commit
33 def __init__(self, hash):
39 self.signoff_set = set()
42 self.rtags = collections.defaultdict(set)
49 def add_change(self, version, info):
50 """Add a new change line to the change list for a version.
53 version: Patch set version (integer: 1, 2, 3)
54 info: Description of change in this version
56 if not self.changes.get(version):
57 self.changes[version] = []
58 self.changes[version].append(info)
61 """Create a list of subject tags in the commit
63 Subject tags look like this:
65 propounder: fort: Change the widget to propound correctly
67 Here the tags are propounder and fort. Multiple tags are supported.
68 The list is updated in self.tag.
71 None if ok, else the name of a tag with no email alias
76 m = re_subject_tag.match(str)
83 def add_cc(self, cc_list):
84 """Add a list of people to Cc when we send this patch.
87 cc_list: List of aliases or email addresses
89 self.cc_list += cc_list
91 def check_duplicate_signoff(self, signoff):
92 """Check a list of signoffs we have send for this patch
97 True if this signoff is new, False if we have already seen it.
99 if signoff in self.signoff_set:
101 self.signoff_set.add(signoff)
104 def add_rtag(self, rtag_type, who):
105 """Add a response tag to a commit
108 key: rtag type (e.g. 'Reviewed-by')
109 who: Person who gave that rtag, e.g. 'Fred Bloggs <fred@bloggs.org>'
111 self.rtags[rtag_type].add(who)