1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2011 The Chromium OS Authors.
7 # Separates a tag: at the beginning of the subject from the rest of it
8 re_subject_tag = re.compile('([^:\s]*):\s*(.*)')
11 """Holds information about a single commit/patch in the series.
14 hash: Commit hash (as a string)
19 tags: List of maintainer tag strings
20 changes: Dict containing a list of changes (single line strings).
21 The dict is indexed by change version (an integer)
22 cc_list: List of people to aliases/emails to cc on this commit
23 notes: List of lines in the commit (not series) notes
24 change_id: the Change-Id: tag that was stripped from this commit
25 and can be used to generate the Message-Id.
27 def __init__(self, hash):
33 self.signoff_set = set()
37 def AddChange(self, version, info):
38 """Add a new change line to the change list for a version.
41 version: Patch set version (integer: 1, 2, 3)
42 info: Description of change in this version
44 if not self.changes.get(version):
45 self.changes[version] = []
46 self.changes[version].append(info)
49 """Create a list of subject tags in the commit
51 Subject tags look like this:
53 propounder: fort: Change the widget to propound correctly
55 Here the tags are propounder and fort. Multiple tags are supported.
56 The list is updated in self.tag.
59 None if ok, else the name of a tag with no email alias
64 m = re_subject_tag.match(str)
71 def AddCc(self, cc_list):
72 """Add a list of people to Cc when we send this patch.
75 cc_list: List of aliases or email addresses
77 self.cc_list += cc_list
79 def CheckDuplicateSignoff(self, signoff):
80 """Check a list of signoffs we have send for this patch
85 True if this signoff is new, False if we have already seen it.
87 if signoff in self.signoff_set:
89 self.signoff_set.add(signoff)