Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 2 | # Copyright (c) 2011 The Chromium OS Authors. |
| 3 | # |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 4 | |
Sean Anderson | 48f46d6 | 2020-05-04 16:28:34 -0400 | [diff] [blame] | 5 | from __future__ import print_function |
| 6 | |
| 7 | import collections |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 8 | import itertools |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 9 | import os |
| 10 | |
Simon Glass | a997ea5 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 11 | from patman import get_maintainer |
| 12 | from patman import gitutil |
| 13 | from patman import settings |
| 14 | from patman import terminal |
| 15 | from patman import tools |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 16 | |
| 17 | # Series-xxx tags that we understand |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 18 | valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name', |
Simon Glass | 420d4ee | 2015-08-22 18:28:01 -0600 | [diff] [blame] | 19 | 'cover_cc', 'process_log'] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 20 | |
| 21 | class Series(dict): |
| 22 | """Holds information about a patch series, including all tags. |
| 23 | |
| 24 | Vars: |
| 25 | cc: List of aliases/emails to Cc all patches to |
| 26 | commits: List of Commit objects, one for each patch |
| 27 | cover: List of lines in the cover letter |
| 28 | notes: List of lines in the notes |
| 29 | changes: (dict) List of changes for each version, The key is |
| 30 | the integer version number |
Simon Glass | 29c5abc | 2013-05-02 14:46:02 +0000 | [diff] [blame] | 31 | allow_overwrite: Allow tags to overwrite an existing tag |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 32 | """ |
| 33 | def __init__(self): |
| 34 | self.cc = [] |
| 35 | self.to = [] |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 36 | self.cover_cc = [] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 37 | self.commits = [] |
| 38 | self.cover = None |
| 39 | self.notes = [] |
| 40 | self.changes = {} |
Simon Glass | 29c5abc | 2013-05-02 14:46:02 +0000 | [diff] [blame] | 41 | self.allow_overwrite = False |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 42 | |
Doug Anderson | 507e8e8 | 2012-12-03 14:40:42 +0000 | [diff] [blame] | 43 | # Written in MakeCcFile() |
| 44 | # key: name of patch file |
| 45 | # value: list of email addresses |
| 46 | self._generated_cc = {} |
| 47 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 48 | # These make us more like a dictionary |
| 49 | def __setattr__(self, name, value): |
| 50 | self[name] = value |
| 51 | |
| 52 | def __getattr__(self, name): |
| 53 | return self[name] |
| 54 | |
| 55 | def AddTag(self, commit, line, name, value): |
| 56 | """Add a new Series-xxx tag along with its value. |
| 57 | |
| 58 | Args: |
| 59 | line: Source line containing tag (useful for debug/error messages) |
| 60 | name: Tag name (part after 'Series-') |
| 61 | value: Tag value (part after 'Series-xxx: ') |
| 62 | """ |
| 63 | # If we already have it, then add to our list |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 64 | name = name.replace('-', '_') |
Simon Glass | 29c5abc | 2013-05-02 14:46:02 +0000 | [diff] [blame] | 65 | if name in self and not self.allow_overwrite: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 66 | values = value.split(',') |
| 67 | values = [str.strip() for str in values] |
| 68 | if type(self[name]) != type([]): |
| 69 | raise ValueError("In %s: line '%s': Cannot add another value " |
| 70 | "'%s' to series '%s'" % |
| 71 | (commit.hash, line, values, self[name])) |
| 72 | self[name] += values |
| 73 | |
| 74 | # Otherwise just set the value |
| 75 | elif name in valid_series: |
Albert ARIBAUD | 77ec8bc | 2016-02-02 10:24:53 +0100 | [diff] [blame] | 76 | if name=="notes": |
| 77 | self[name] = [value] |
| 78 | else: |
| 79 | self[name] = value |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 80 | else: |
| 81 | raise ValueError("In %s: line '%s': Unknown 'Series-%s': valid " |
Simon Glass | e7ecd3f | 2012-09-27 15:06:02 +0000 | [diff] [blame] | 82 | "options are %s" % (commit.hash, line, name, |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 83 | ', '.join(valid_series))) |
| 84 | |
| 85 | def AddCommit(self, commit): |
| 86 | """Add a commit into our list of commits |
| 87 | |
| 88 | We create a list of tags in the commit subject also. |
| 89 | |
| 90 | Args: |
| 91 | commit: Commit object to add |
| 92 | """ |
| 93 | commit.CheckTags() |
| 94 | self.commits.append(commit) |
| 95 | |
| 96 | def ShowActions(self, args, cmd, process_tags): |
| 97 | """Show what actions we will/would perform |
| 98 | |
| 99 | Args: |
| 100 | args: List of patch files we created |
| 101 | cmd: The git command we would have run |
| 102 | process_tags: Process tags as if they were aliases |
| 103 | """ |
Peter Tyser | c6af802 | 2015-01-26 11:42:21 -0600 | [diff] [blame] | 104 | to_set = set(gitutil.BuildEmailList(self.to)); |
| 105 | cc_set = set(gitutil.BuildEmailList(self.cc)); |
| 106 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 107 | col = terminal.Color() |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 108 | print('Dry run, so not doing much. But I would do this:') |
| 109 | print() |
| 110 | print('Send a total of %d patch%s with %scover letter.' % ( |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 111 | len(args), '' if len(args) == 1 else 'es', |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 112 | self.get('cover') and 'a ' or 'no ')) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 113 | |
| 114 | # TODO: Colour the patches according to whether they passed checks |
| 115 | for upto in range(len(args)): |
| 116 | commit = self.commits[upto] |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 117 | print(col.Color(col.GREEN, ' %s' % args[upto])) |
Doug Anderson | 507e8e8 | 2012-12-03 14:40:42 +0000 | [diff] [blame] | 118 | cc_list = list(self._generated_cc[commit.patch]) |
Simon Glass | 3ab178f | 2019-05-14 15:53:51 -0600 | [diff] [blame] | 119 | for email in sorted(set(cc_list) - to_set - cc_set): |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 120 | if email == None: |
| 121 | email = col.Color(col.YELLOW, "<alias '%s' not found>" |
| 122 | % tag) |
| 123 | if email: |
Simon Glass | 22c5834 | 2017-05-29 15:31:23 -0600 | [diff] [blame] | 124 | print(' Cc: ', email) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 125 | print |
Simon Glass | 3ab178f | 2019-05-14 15:53:51 -0600 | [diff] [blame] | 126 | for item in sorted(to_set): |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 127 | print('To:\t ', item) |
Simon Glass | 3ab178f | 2019-05-14 15:53:51 -0600 | [diff] [blame] | 128 | for item in sorted(cc_set - to_set): |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 129 | print('Cc:\t ', item) |
| 130 | print('Version: ', self.get('version')) |
| 131 | print('Prefix:\t ', self.get('prefix')) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 132 | if self.cover: |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 133 | print('Cover: %d lines' % len(self.cover)) |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 134 | cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) |
| 135 | all_ccs = itertools.chain(cover_cc, *self._generated_cc.values()) |
Simon Glass | 3ab178f | 2019-05-14 15:53:51 -0600 | [diff] [blame] | 136 | for email in sorted(set(all_ccs) - to_set - cc_set): |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 137 | print(' Cc: ', email) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 138 | if cmd: |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 139 | print('Git command: %s' % cmd) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 140 | |
| 141 | def MakeChangeLog(self, commit): |
| 142 | """Create a list of changes for each version. |
| 143 | |
| 144 | Return: |
| 145 | The change log as a list of strings, one per line |
| 146 | |
Simon Glass | aa912af | 2012-10-30 06:15:16 +0000 | [diff] [blame] | 147 | Changes in v4: |
Otavio Salvador | cc1fbaa | 2012-08-18 07:46:04 +0000 | [diff] [blame] | 148 | - Jog the dial back closer to the widget |
| 149 | |
Simon Glass | aa912af | 2012-10-30 06:15:16 +0000 | [diff] [blame] | 150 | Changes in v2: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 151 | - Fix the widget |
| 152 | - Jog the dial |
| 153 | |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 154 | If there are no new changes in a patch, a note will be added |
| 155 | |
| 156 | (no changes since v2) |
| 157 | |
| 158 | Changes in v2: |
| 159 | - Fix the widget |
| 160 | - Jog the dial |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 161 | """ |
Sean Anderson | 48f46d6 | 2020-05-04 16:28:34 -0400 | [diff] [blame] | 162 | # Collect changes from the series and this commit |
| 163 | changes = collections.defaultdict(list) |
| 164 | for version, changelist in self.changes.items(): |
| 165 | changes[version] += changelist |
| 166 | if commit: |
| 167 | for version, changelist in commit.changes.items(): |
| 168 | changes[version] += [[commit, text] for text in changelist] |
| 169 | |
| 170 | versions = sorted(changes, reverse=True) |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 171 | newest_version = 1 |
| 172 | if 'version' in self: |
| 173 | newest_version = max(newest_version, int(self.version)) |
| 174 | if versions: |
| 175 | newest_version = max(newest_version, versions[0]) |
| 176 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 177 | final = [] |
Simon Glass | ec1d042 | 2013-03-26 13:09:44 +0000 | [diff] [blame] | 178 | process_it = self.get('process_log', '').split(',') |
| 179 | process_it = [item.strip() for item in process_it] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 180 | need_blank = False |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 181 | for version in versions: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 182 | out = [] |
Sean Anderson | 48f46d6 | 2020-05-04 16:28:34 -0400 | [diff] [blame] | 183 | for this_commit, text in changes[version]: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 184 | if commit and this_commit != commit: |
| 185 | continue |
Simon Glass | ec1d042 | 2013-03-26 13:09:44 +0000 | [diff] [blame] | 186 | if 'uniq' not in process_it or text not in out: |
| 187 | out.append(text) |
Simon Glass | ec1d042 | 2013-03-26 13:09:44 +0000 | [diff] [blame] | 188 | if 'sort' in process_it: |
| 189 | out = sorted(out) |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 190 | have_changes = len(out) > 0 |
| 191 | line = 'Changes in v%d:' % version |
Simon Glass | aa912af | 2012-10-30 06:15:16 +0000 | [diff] [blame] | 192 | if have_changes: |
| 193 | out.insert(0, line) |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 194 | if version < newest_version and len(final) == 0: |
| 195 | out.insert(0, '') |
| 196 | out.insert(0, '(no changes since v%d)' % version) |
| 197 | newest_version = 0 |
| 198 | # Only add a new line if we output something |
| 199 | if need_blank: |
| 200 | out.insert(0, '') |
| 201 | need_blank = False |
Simon Glass | aa912af | 2012-10-30 06:15:16 +0000 | [diff] [blame] | 202 | final += out |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 203 | need_blank = need_blank or have_changes |
| 204 | |
| 205 | if len(final) > 0: |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 206 | final.append('') |
Sean Anderson | 5ae4e8d | 2020-05-04 16:28:33 -0400 | [diff] [blame] | 207 | elif newest_version != 1: |
| 208 | final = ['(no changes since v1)', ''] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 209 | return final |
| 210 | |
| 211 | def DoChecks(self): |
| 212 | """Check that each version has a change log |
| 213 | |
| 214 | Print an error if something is wrong. |
| 215 | """ |
| 216 | col = terminal.Color() |
| 217 | if self.get('version'): |
| 218 | changes_copy = dict(self.changes) |
Otavio Salvador | fe07d07 | 2012-08-13 10:08:22 +0000 | [diff] [blame] | 219 | for version in range(1, int(self.version) + 1): |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 220 | if self.changes.get(version): |
| 221 | del changes_copy[version] |
| 222 | else: |
Otavio Salvador | fe07d07 | 2012-08-13 10:08:22 +0000 | [diff] [blame] | 223 | if version > 1: |
| 224 | str = 'Change log missing for v%d' % version |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 225 | print(col.Color(col.RED, str)) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 226 | for version in changes_copy: |
| 227 | str = 'Change log for unknown version v%d' % version |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 228 | print(col.Color(col.RED, str)) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 229 | elif self.changes: |
| 230 | str = 'Change log exists, but no version is set' |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 231 | print(col.Color(col.RED, str)) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 232 | |
Simon Glass | 46b84d8 | 2014-09-14 20:23:17 -0600 | [diff] [blame] | 233 | def MakeCcFile(self, process_tags, cover_fname, raise_on_error, |
Chris Packham | b84fb48 | 2018-06-07 20:45:06 +1200 | [diff] [blame] | 234 | add_maintainers, limit): |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 235 | """Make a cc file for us to use for per-commit Cc automation |
| 236 | |
Doug Anderson | 507e8e8 | 2012-12-03 14:40:42 +0000 | [diff] [blame] | 237 | Also stores in self._generated_cc to make ShowActions() faster. |
| 238 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 239 | Args: |
| 240 | process_tags: Process tags as if they were aliases |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 241 | cover_fname: If non-None the name of the cover letter. |
Simon Glass | 12ea5f4 | 2013-03-26 13:09:42 +0000 | [diff] [blame] | 242 | raise_on_error: True to raise an error when an alias fails to match, |
| 243 | False to just print a message. |
Simon Glass | b712eed | 2017-05-29 15:31:29 -0600 | [diff] [blame] | 244 | add_maintainers: Either: |
| 245 | True/False to call the get_maintainers to CC maintainers |
| 246 | List of maintainers to include (for testing) |
Simon Glass | 24725af | 2020-07-05 21:41:49 -0600 | [diff] [blame] | 247 | limit: Limit the length of the Cc list (None if no limit) |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 248 | Return: |
| 249 | Filename of temp file created |
| 250 | """ |
Chris Packham | e8d2a12 | 2017-09-01 20:57:53 +1200 | [diff] [blame] | 251 | col = terminal.Color() |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 252 | # Look for commit tags (of the form 'xxx:' at the start of the subject) |
| 253 | fname = '/tmp/patman.%d' % os.getpid() |
Simon Glass | f544a2d | 2019-10-31 07:42:51 -0600 | [diff] [blame] | 254 | fd = open(fname, 'w', encoding='utf-8') |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 255 | all_ccs = [] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 256 | for commit in self.commits: |
Simon Glass | 0f94fa7 | 2017-05-29 15:31:30 -0600 | [diff] [blame] | 257 | cc = [] |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 258 | if process_tags: |
Simon Glass | 0f94fa7 | 2017-05-29 15:31:30 -0600 | [diff] [blame] | 259 | cc += gitutil.BuildEmailList(commit.tags, |
Simon Glass | 12ea5f4 | 2013-03-26 13:09:42 +0000 | [diff] [blame] | 260 | raise_on_error=raise_on_error) |
Simon Glass | 0f94fa7 | 2017-05-29 15:31:30 -0600 | [diff] [blame] | 261 | cc += gitutil.BuildEmailList(commit.cc_list, |
Simon Glass | 12ea5f4 | 2013-03-26 13:09:42 +0000 | [diff] [blame] | 262 | raise_on_error=raise_on_error) |
Simon Glass | 0f94fa7 | 2017-05-29 15:31:30 -0600 | [diff] [blame] | 263 | if type(add_maintainers) == type(cc): |
| 264 | cc += add_maintainers |
Simon Glass | b712eed | 2017-05-29 15:31:29 -0600 | [diff] [blame] | 265 | elif add_maintainers: |
Simon Glass | c9fa886 | 2020-06-07 06:45:48 -0600 | [diff] [blame] | 266 | dir_list = [os.path.join(gitutil.GetTopLevel(), 'scripts')] |
| 267 | cc += get_maintainer.GetMaintainer(dir_list, commit.patch) |
Chris Packham | e8d2a12 | 2017-09-01 20:57:53 +1200 | [diff] [blame] | 268 | for x in set(cc) & set(settings.bounces): |
| 269 | print(col.Color(col.YELLOW, 'Skipping "%s"' % x)) |
| 270 | cc = set(cc) - set(settings.bounces) |
Simon Glass | b097696 | 2019-05-14 15:53:54 -0600 | [diff] [blame] | 271 | cc = [tools.FromUnicode(m) for m in cc] |
Chris Packham | b84fb48 | 2018-06-07 20:45:06 +1200 | [diff] [blame] | 272 | if limit is not None: |
| 273 | cc = cc[:limit] |
Simon Glass | 0f94fa7 | 2017-05-29 15:31:30 -0600 | [diff] [blame] | 274 | all_ccs += cc |
Dmitry Torokhov | ef7f67d | 2019-10-21 20:09:56 -0700 | [diff] [blame] | 275 | print(commit.patch, '\0'.join(sorted(set(cc))), file=fd) |
Simon Glass | 0f94fa7 | 2017-05-29 15:31:30 -0600 | [diff] [blame] | 276 | self._generated_cc[commit.patch] = cc |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 277 | |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 278 | if cover_fname: |
Simon Glass | c72f3da | 2013-03-20 16:43:00 +0000 | [diff] [blame] | 279 | cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) |
Simon Glass | b097696 | 2019-05-14 15:53:54 -0600 | [diff] [blame] | 280 | cover_cc = [tools.FromUnicode(m) for m in cover_cc] |
Simon Glass | 39ed6bb | 2020-02-27 18:49:23 -0700 | [diff] [blame] | 281 | cover_cc = list(set(cover_cc + all_ccs)) |
| 282 | if limit is not None: |
| 283 | cover_cc = cover_cc[:limit] |
| 284 | cc_list = '\0'.join([tools.ToUnicode(x) for x in sorted(cover_cc)]) |
Robert Beckett | 3356f2c | 2019-11-13 18:39:45 +0000 | [diff] [blame] | 285 | print(cover_fname, cc_list, file=fd) |
Doug Anderson | 05416af | 2012-12-03 14:40:43 +0000 | [diff] [blame] | 286 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 287 | fd.close() |
| 288 | return fname |
| 289 | |
| 290 | def AddChange(self, version, commit, info): |
| 291 | """Add a new change line to a version. |
| 292 | |
| 293 | This will later appear in the change log. |
| 294 | |
| 295 | Args: |
| 296 | version: version number to add change list to |
| 297 | info: change line for this version |
| 298 | """ |
| 299 | if not self.changes.get(version): |
| 300 | self.changes[version] = [] |
| 301 | self.changes[version].append([commit, info]) |
| 302 | |
| 303 | def GetPatchPrefix(self): |
| 304 | """Get the patch version string |
| 305 | |
| 306 | Return: |
| 307 | Patch string, like 'RFC PATCH v5' or just 'PATCH' |
| 308 | """ |
Wu, Josh | 9873b91 | 2015-04-15 10:25:18 +0800 | [diff] [blame] | 309 | git_prefix = gitutil.GetDefaultSubjectPrefix() |
| 310 | if git_prefix: |
Paul Burton | a5edb44 | 2016-09-27 16:03:49 +0100 | [diff] [blame] | 311 | git_prefix = '%s][' % git_prefix |
Wu, Josh | 9873b91 | 2015-04-15 10:25:18 +0800 | [diff] [blame] | 312 | else: |
| 313 | git_prefix = '' |
| 314 | |
Simon Glass | 2613288 | 2012-01-14 15:12:45 +0000 | [diff] [blame] | 315 | version = '' |
| 316 | if self.get('version'): |
| 317 | version = ' v%s' % self['version'] |
| 318 | |
| 319 | # Get patch name prefix |
| 320 | prefix = '' |
| 321 | if self.get('prefix'): |
| 322 | prefix = '%s ' % self['prefix'] |
Wu, Josh | 9873b91 | 2015-04-15 10:25:18 +0800 | [diff] [blame] | 323 | return '%s%sPATCH%s' % (git_prefix, prefix, version) |