]>
Commit | Line | Data |
---|---|---|
0d24de9d SG |
1 | # Copyright (c) 2011 The Chromium OS Authors. |
2 | # | |
1a459660 | 3 | # SPDX-License-Identifier: GPL-2.0+ |
0d24de9d SG |
4 | # |
5 | ||
6 | import re | |
7 | ||
8 | # Separates a tag: at the beginning of the subject from the rest of it | |
ed922275 | 9 | re_subject_tag = re.compile('([^:\s]*):\s*(.*)') |
0d24de9d SG |
10 | |
11 | class Commit: | |
12 | """Holds information about a single commit/patch in the series. | |
13 | ||
14 | Args: | |
15 | hash: Commit hash (as a string) | |
16 | ||
17 | Variables: | |
18 | hash: Commit hash | |
19 | subject: Subject line | |
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 | """ | |
25 | def __init__(self, hash): | |
26 | self.hash = hash | |
27 | self.subject = None | |
28 | self.tags = [] | |
29 | self.changes = {} | |
30 | self.cc_list = [] | |
31 | ||
32 | def AddChange(self, version, info): | |
33 | """Add a new change line to the change list for a version. | |
34 | ||
35 | Args: | |
36 | version: Patch set version (integer: 1, 2, 3) | |
37 | info: Description of change in this version | |
38 | """ | |
39 | if not self.changes.get(version): | |
40 | self.changes[version] = [] | |
41 | self.changes[version].append(info) | |
42 | ||
43 | def CheckTags(self): | |
44 | """Create a list of subject tags in the commit | |
45 | ||
46 | Subject tags look like this: | |
47 | ||
0d99fe0f | 48 | propounder: fort: Change the widget to propound correctly |
0d24de9d | 49 | |
0d99fe0f SG |
50 | Here the tags are propounder and fort. Multiple tags are supported. |
51 | The list is updated in self.tag. | |
0d24de9d SG |
52 | |
53 | Returns: | |
54 | None if ok, else the name of a tag with no email alias | |
55 | """ | |
56 | str = self.subject | |
57 | m = True | |
58 | while m: | |
59 | m = re_subject_tag.match(str) | |
60 | if m: | |
61 | tag = m.group(1) | |
62 | self.tags.append(tag) | |
63 | str = m.group(2) | |
64 | return None | |
65 | ||
66 | def AddCc(self, cc_list): | |
67 | """Add a list of people to Cc when we send this patch. | |
68 | ||
69 | Args: | |
70 | cc_list: List of aliases or email addresses | |
71 | """ | |
72 | self.cc_list += cc_list |