Simon Glass | 0d24de9 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 1 | # Copyright (c) 2011 The Chromium OS Authors. |
| 2 | # |
| 3 | # See file CREDITS for list of people who contributed to this |
| 4 | # project. |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or |
| 7 | # modify it under the terms of the GNU General Public License as |
| 8 | # published by the Free Software Foundation; either version 2 of |
| 9 | # the License, or (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program; if not, write to the Free Software |
| 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 19 | # MA 02111-1307 USA |
| 20 | # |
| 21 | |
| 22 | import re |
| 23 | |
| 24 | # Separates a tag: at the beginning of the subject from the rest of it |
Simon Glass | ed92227 | 2013-03-26 13:09:40 +0000 | [diff] [blame] | 25 | re_subject_tag = re.compile('([^:\s]*):\s*(.*)') |
Simon Glass | 0d24de9 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 26 | |
| 27 | class Commit: |
| 28 | """Holds information about a single commit/patch in the series. |
| 29 | |
| 30 | Args: |
| 31 | hash: Commit hash (as a string) |
| 32 | |
| 33 | Variables: |
| 34 | hash: Commit hash |
| 35 | subject: Subject line |
| 36 | tags: List of maintainer tag strings |
| 37 | changes: Dict containing a list of changes (single line strings). |
| 38 | The dict is indexed by change version (an integer) |
| 39 | cc_list: List of people to aliases/emails to cc on this commit |
| 40 | """ |
| 41 | def __init__(self, hash): |
| 42 | self.hash = hash |
| 43 | self.subject = None |
| 44 | self.tags = [] |
| 45 | self.changes = {} |
| 46 | self.cc_list = [] |
| 47 | |
| 48 | def AddChange(self, version, info): |
| 49 | """Add a new change line to the change list for a version. |
| 50 | |
| 51 | Args: |
| 52 | version: Patch set version (integer: 1, 2, 3) |
| 53 | info: Description of change in this version |
| 54 | """ |
| 55 | if not self.changes.get(version): |
| 56 | self.changes[version] = [] |
| 57 | self.changes[version].append(info) |
| 58 | |
| 59 | def CheckTags(self): |
| 60 | """Create a list of subject tags in the commit |
| 61 | |
| 62 | Subject tags look like this: |
| 63 | |
Simon Glass | 0d99fe0 | 2013-03-26 13:09:41 +0000 | [diff] [blame^] | 64 | propounder: fort: Change the widget to propound correctly |
Simon Glass | 0d24de9 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 65 | |
Simon Glass | 0d99fe0 | 2013-03-26 13:09:41 +0000 | [diff] [blame^] | 66 | Here the tags are propounder and fort. Multiple tags are supported. |
| 67 | The list is updated in self.tag. |
Simon Glass | 0d24de9 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 68 | |
| 69 | Returns: |
| 70 | None if ok, else the name of a tag with no email alias |
| 71 | """ |
| 72 | str = self.subject |
| 73 | m = True |
| 74 | while m: |
| 75 | m = re_subject_tag.match(str) |
| 76 | if m: |
| 77 | tag = m.group(1) |
| 78 | self.tags.append(tag) |
| 79 | str = m.group(2) |
| 80 | return None |
| 81 | |
| 82 | def AddCc(self, cc_list): |
| 83 | """Add a list of people to Cc when we send this patch. |
| 84 | |
| 85 | Args: |
| 86 | cc_list: List of aliases or email addresses |
| 87 | """ |
| 88 | self.cc_list += cc_list |