blob: 3d48836e90a566cb211f079787c315d61bb6884c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glass26132882012-01-14 15:12:45 +00002# Copyright (c) 2011 The Chromium OS Authors.
3#
Simon Glass26132882012-01-14 15:12:45 +00004
Sean Anderson48f46d62020-05-04 16:28:34 -04005from __future__ import print_function
6
7import collections
Simon Glass620639c2023-03-08 10:52:54 -08008import concurrent.futures
Doug Anderson05416af2012-12-03 14:40:43 +00009import itertools
Simon Glass26132882012-01-14 15:12:45 +000010import os
Simon Glass620639c2023-03-08 10:52:54 -080011import sys
12import time
Simon Glass26132882012-01-14 15:12:45 +000013
Simon Glassa997ea52020-04-17 18:09:04 -060014from patman import get_maintainer
Simon Glassa997ea52020-04-17 18:09:04 -060015from patman import settings
Simon Glassba1b3b92025-02-09 14:26:00 -070016from u_boot_pylib import gitutil
Simon Glass131444f2023-02-23 18:18:04 -070017from u_boot_pylib import terminal
18from u_boot_pylib import tools
Simon Glass26132882012-01-14 15:12:45 +000019
20# Series-xxx tags that we understand
Simon Glassc72f3da2013-03-20 16:43:00 +000021valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
Sean Andersondc1cd132021-10-22 19:07:04 -040022 'cover_cc', 'process_log', 'links', 'patchwork_url', 'postfix']
Simon Glass26132882012-01-14 15:12:45 +000023
24class Series(dict):
25 """Holds information about a patch series, including all tags.
26
27 Vars:
Simon Glass27d6f0f2025-05-08 06:35:42 +020028 cc (list of str): Aliases/emails to Cc all patches to
29 to (list of str): Aliases/emails to send patches to
30 commits (list of Commit): Commit objects, one for each patch
31 cover (list of str): Lines in the cover letter
32 notes (list of str): Lines in the notes
33 changes: (dict) List of changes for each version:
34 key (int): version number
35 value: tuple:
36 commit (Commit): Commit this relates to, or None if related to a
37 cover letter
38 info (str): change lines for this version (separated by \n)
39 allow_overwrite (bool): Allow tags to overwrite an existing tag
40 base_commit (Commit): Commit object at the base of this series
41 branch (str): Branch name of this series
Simon Glass985f72a2025-05-10 13:05:10 +020042 desc (str): Description of the series (cover-letter title)
43 idnum (int or None): Database rowid
44 name (str): Series name, typically the branch name without any numeric
45 suffix
Simon Glass27d6f0f2025-05-08 06:35:42 +020046 _generated_cc (dict) written in MakeCcFile()
47 key: name of patch file
48 value: list of email addresses
Simon Glass26132882012-01-14 15:12:45 +000049 """
50 def __init__(self):
51 self.cc = []
52 self.to = []
Simon Glassc72f3da2013-03-20 16:43:00 +000053 self.cover_cc = []
Simon Glass26132882012-01-14 15:12:45 +000054 self.commits = []
55 self.cover = None
56 self.notes = []
57 self.changes = {}
Simon Glass29c5abc2013-05-02 14:46:02 +000058 self.allow_overwrite = False
Simon Glass414f1e02025-02-27 12:27:30 -070059 self.base_commit = None
60 self.branch = None
Simon Glass985f72a2025-05-10 13:05:10 +020061 self.desc = ''
62 self.idnum = None
63 self.name = None
Doug Anderson507e8e82012-12-03 14:40:42 +000064 self._generated_cc = {}
65
Simon Glass26132882012-01-14 15:12:45 +000066 # These make us more like a dictionary
67 def __setattr__(self, name, value):
68 self[name] = value
69
70 def __getattr__(self, name):
71 return self[name]
72
Simon Glass985f72a2025-05-10 13:05:10 +020073 @staticmethod
74 def from_fields(idnum, name, desc):
75 ser = Series()
76 ser.idnum = idnum
77 ser.name = name
78 ser.desc = desc
79 return ser
80
Simon Glass26132882012-01-14 15:12:45 +000081 def AddTag(self, commit, line, name, value):
82 """Add a new Series-xxx tag along with its value.
83
84 Args:
85 line: Source line containing tag (useful for debug/error messages)
86 name: Tag name (part after 'Series-')
87 value: Tag value (part after 'Series-xxx: ')
Simon Glass8093a8f2020-10-29 21:46:25 -060088
89 Returns:
90 String warning if something went wrong, else None
Simon Glass26132882012-01-14 15:12:45 +000091 """
92 # If we already have it, then add to our list
Simon Glassc72f3da2013-03-20 16:43:00 +000093 name = name.replace('-', '_')
Simon Glass29c5abc2013-05-02 14:46:02 +000094 if name in self and not self.allow_overwrite:
Simon Glass26132882012-01-14 15:12:45 +000095 values = value.split(',')
96 values = [str.strip() for str in values]
97 if type(self[name]) != type([]):
98 raise ValueError("In %s: line '%s': Cannot add another value "
99 "'%s' to series '%s'" %
100 (commit.hash, line, values, self[name]))
101 self[name] += values
102
103 # Otherwise just set the value
104 elif name in valid_series:
Albert ARIBAUD77ec8bc2016-02-02 10:24:53 +0100105 if name=="notes":
106 self[name] = [value]
107 else:
108 self[name] = value
Simon Glass26132882012-01-14 15:12:45 +0000109 else:
Simon Glass8093a8f2020-10-29 21:46:25 -0600110 return ("In %s: line '%s': Unknown 'Series-%s': valid "
Simon Glasse7ecd3f2012-09-27 15:06:02 +0000111 "options are %s" % (commit.hash, line, name,
Simon Glass26132882012-01-14 15:12:45 +0000112 ', '.join(valid_series)))
Simon Glass8093a8f2020-10-29 21:46:25 -0600113 return None
Simon Glass26132882012-01-14 15:12:45 +0000114
115 def AddCommit(self, commit):
116 """Add a commit into our list of commits
117
118 We create a list of tags in the commit subject also.
119
120 Args:
121 commit: Commit object to add
122 """
Simon Glass530ac272022-01-29 14:14:07 -0700123 commit.check_tags()
Simon Glass26132882012-01-14 15:12:45 +0000124 self.commits.append(commit)
125
Simon Glass32f12a7e2025-04-07 22:51:47 +1200126 def ShowActions(self, args, cmd, process_tags, alias):
Simon Glass26132882012-01-14 15:12:45 +0000127 """Show what actions we will/would perform
128
129 Args:
130 args: List of patch files we created
131 cmd: The git command we would have run
132 process_tags: Process tags as if they were aliases
Simon Glass32f12a7e2025-04-07 22:51:47 +1200133 alias (dict): Alias dictionary
134 key: alias
135 value: list of aliases or email addresses
Simon Glass26132882012-01-14 15:12:45 +0000136 """
Simon Glass32f12a7e2025-04-07 22:51:47 +1200137 to_set = set(gitutil.build_email_list(self.to, alias));
138 cc_set = set(gitutil.build_email_list(self.cc, alias));
Peter Tyserc6af8022015-01-26 11:42:21 -0600139
Simon Glass26132882012-01-14 15:12:45 +0000140 col = terminal.Color()
Paul Burtonc3931342016-09-27 16:03:50 +0100141 print('Dry run, so not doing much. But I would do this:')
142 print()
143 print('Send a total of %d patch%s with %scover letter.' % (
Simon Glass26132882012-01-14 15:12:45 +0000144 len(args), '' if len(args) == 1 else 'es',
Paul Burtonc3931342016-09-27 16:03:50 +0100145 self.get('cover') and 'a ' or 'no '))
Simon Glass26132882012-01-14 15:12:45 +0000146
147 # TODO: Colour the patches according to whether they passed checks
148 for upto in range(len(args)):
149 commit = self.commits[upto]
Simon Glassf45d3742022-01-29 14:14:17 -0700150 print(col.build(col.GREEN, ' %s' % args[upto]))
Doug Anderson507e8e82012-12-03 14:40:42 +0000151 cc_list = list(self._generated_cc[commit.patch])
Simon Glass3ab178f2019-05-14 15:53:51 -0600152 for email in sorted(set(cc_list) - to_set - cc_set):
Simon Glass26132882012-01-14 15:12:45 +0000153 if email == None:
Simon Glass547cba62022-02-11 13:23:18 -0700154 email = col.build(col.YELLOW, '<alias not found>')
Simon Glass26132882012-01-14 15:12:45 +0000155 if email:
Simon Glass22c58342017-05-29 15:31:23 -0600156 print(' Cc: ', email)
Simon Glass26132882012-01-14 15:12:45 +0000157 print
Simon Glass3ab178f2019-05-14 15:53:51 -0600158 for item in sorted(to_set):
Paul Burtonc3931342016-09-27 16:03:50 +0100159 print('To:\t ', item)
Simon Glass3ab178f2019-05-14 15:53:51 -0600160 for item in sorted(cc_set - to_set):
Paul Burtonc3931342016-09-27 16:03:50 +0100161 print('Cc:\t ', item)
162 print('Version: ', self.get('version'))
163 print('Prefix:\t ', self.get('prefix'))
Sean Andersondc1cd132021-10-22 19:07:04 -0400164 print('Postfix:\t ', self.get('postfix'))
Simon Glass26132882012-01-14 15:12:45 +0000165 if self.cover:
Paul Burtonc3931342016-09-27 16:03:50 +0100166 print('Cover: %d lines' % len(self.cover))
Simon Glassdea1ddf2025-04-07 22:51:44 +1200167 cover_cc = gitutil.build_email_list(self.get('cover_cc', ''),
Simon Glass32f12a7e2025-04-07 22:51:47 +1200168 alias)
Simon Glassc72f3da2013-03-20 16:43:00 +0000169 all_ccs = itertools.chain(cover_cc, *self._generated_cc.values())
Simon Glass3ab178f2019-05-14 15:53:51 -0600170 for email in sorted(set(all_ccs) - to_set - cc_set):
Paul Burtonc3931342016-09-27 16:03:50 +0100171 print(' Cc: ', email)
Simon Glass26132882012-01-14 15:12:45 +0000172 if cmd:
Paul Burtonc3931342016-09-27 16:03:50 +0100173 print('Git command: %s' % cmd)
Simon Glass26132882012-01-14 15:12:45 +0000174
175 def MakeChangeLog(self, commit):
176 """Create a list of changes for each version.
177
178 Return:
179 The change log as a list of strings, one per line
180
Simon Glassaa912af2012-10-30 06:15:16 +0000181 Changes in v4:
Otavio Salvadorcc1fbaa2012-08-18 07:46:04 +0000182 - Jog the dial back closer to the widget
183
Simon Glassaa912af2012-10-30 06:15:16 +0000184 Changes in v2:
Simon Glass26132882012-01-14 15:12:45 +0000185 - Fix the widget
186 - Jog the dial
187
Sean Anderson5ae4e8d2020-05-04 16:28:33 -0400188 If there are no new changes in a patch, a note will be added
189
190 (no changes since v2)
191
192 Changes in v2:
193 - Fix the widget
194 - Jog the dial
Simon Glass26132882012-01-14 15:12:45 +0000195 """
Sean Anderson48f46d62020-05-04 16:28:34 -0400196 # Collect changes from the series and this commit
197 changes = collections.defaultdict(list)
198 for version, changelist in self.changes.items():
199 changes[version] += changelist
200 if commit:
201 for version, changelist in commit.changes.items():
202 changes[version] += [[commit, text] for text in changelist]
203
204 versions = sorted(changes, reverse=True)
Sean Anderson5ae4e8d2020-05-04 16:28:33 -0400205 newest_version = 1
206 if 'version' in self:
207 newest_version = max(newest_version, int(self.version))
208 if versions:
209 newest_version = max(newest_version, versions[0])
210
Simon Glass26132882012-01-14 15:12:45 +0000211 final = []
Simon Glassec1d0422013-03-26 13:09:44 +0000212 process_it = self.get('process_log', '').split(',')
213 process_it = [item.strip() for item in process_it]
Simon Glass26132882012-01-14 15:12:45 +0000214 need_blank = False
Sean Anderson5ae4e8d2020-05-04 16:28:33 -0400215 for version in versions:
Simon Glass26132882012-01-14 15:12:45 +0000216 out = []
Sean Anderson48f46d62020-05-04 16:28:34 -0400217 for this_commit, text in changes[version]:
Simon Glass26132882012-01-14 15:12:45 +0000218 if commit and this_commit != commit:
219 continue
Simon Glassec1d0422013-03-26 13:09:44 +0000220 if 'uniq' not in process_it or text not in out:
221 out.append(text)
Simon Glassec1d0422013-03-26 13:09:44 +0000222 if 'sort' in process_it:
223 out = sorted(out)
Sean Anderson5ae4e8d2020-05-04 16:28:33 -0400224 have_changes = len(out) > 0
225 line = 'Changes in v%d:' % version
Simon Glassaa912af2012-10-30 06:15:16 +0000226 if have_changes:
227 out.insert(0, line)
Sean Anderson5ae4e8d2020-05-04 16:28:33 -0400228 if version < newest_version and len(final) == 0:
229 out.insert(0, '')
230 out.insert(0, '(no changes since v%d)' % version)
231 newest_version = 0
232 # Only add a new line if we output something
233 if need_blank:
234 out.insert(0, '')
235 need_blank = False
Simon Glassaa912af2012-10-30 06:15:16 +0000236 final += out
Sean Anderson5ae4e8d2020-05-04 16:28:33 -0400237 need_blank = need_blank or have_changes
238
239 if len(final) > 0:
Simon Glass26132882012-01-14 15:12:45 +0000240 final.append('')
Sean Anderson5ae4e8d2020-05-04 16:28:33 -0400241 elif newest_version != 1:
242 final = ['(no changes since v1)', '']
Simon Glass26132882012-01-14 15:12:45 +0000243 return final
244
245 def DoChecks(self):
246 """Check that each version has a change log
247
248 Print an error if something is wrong.
249 """
250 col = terminal.Color()
251 if self.get('version'):
252 changes_copy = dict(self.changes)
Otavio Salvadorfe07d072012-08-13 10:08:22 +0000253 for version in range(1, int(self.version) + 1):
Simon Glass26132882012-01-14 15:12:45 +0000254 if self.changes.get(version):
255 del changes_copy[version]
256 else:
Otavio Salvadorfe07d072012-08-13 10:08:22 +0000257 if version > 1:
258 str = 'Change log missing for v%d' % version
Simon Glassf45d3742022-01-29 14:14:17 -0700259 print(col.build(col.RED, str))
Simon Glass26132882012-01-14 15:12:45 +0000260 for version in changes_copy:
261 str = 'Change log for unknown version v%d' % version
Simon Glassf45d3742022-01-29 14:14:17 -0700262 print(col.build(col.RED, str))
Simon Glass26132882012-01-14 15:12:45 +0000263 elif self.changes:
264 str = 'Change log exists, but no version is set'
Simon Glassf45d3742022-01-29 14:14:17 -0700265 print(col.build(col.RED, str))
Simon Glass26132882012-01-14 15:12:45 +0000266
Simon Glass77f57df2023-03-08 10:52:53 -0800267 def GetCcForCommit(self, commit, process_tags, warn_on_error,
268 add_maintainers, limit, get_maintainer_script,
Simon Glass5750cc22025-05-07 18:02:47 +0200269 all_skips, alias, cwd):
Simon Glass77f57df2023-03-08 10:52:53 -0800270 """Get the email CCs to use with a particular commit
271
272 Uses subject tags and get_maintainers.pl script to find people to cc
273 on a patch
274
275 Args:
276 commit (Commit): Commit to process
277 process_tags (bool): Process tags as if they were aliases
278 warn_on_error (bool): True to print a warning when an alias fails to
279 match, False to ignore it.
280 add_maintainers (bool or list of str): Either:
281 True/False to call the get_maintainers to CC maintainers
282 List of maintainers to include (for testing)
283 limit (int): Limit the length of the Cc list (None if no limit)
284 get_maintainer_script (str): The file name of the get_maintainer.pl
285 script (or compatible).
286 all_skips (set of str): Updated to include the set of bouncing email
287 addresses that were dropped from the output. This is essentially
288 a return value from this function.
Simon Glass9938b7b2025-04-07 22:51:46 +1200289 alias (dict): Alias dictionary
290 key: alias
291 value: list of aliases or email addresses
Simon Glass5750cc22025-05-07 18:02:47 +0200292 cwd (str): Path to use for patch filenames (None to use current dir)
Simon Glass77f57df2023-03-08 10:52:53 -0800293
294 Returns:
295 list of str: List of email addresses to cc
296 """
297 cc = []
298 if process_tags:
Simon Glass32f12a7e2025-04-07 22:51:47 +1200299 cc += gitutil.build_email_list(commit.tags, alias,
Simon Glass77f57df2023-03-08 10:52:53 -0800300 warn_on_error=warn_on_error)
Simon Glass32f12a7e2025-04-07 22:51:47 +1200301 cc += gitutil.build_email_list(commit.cc_list, alias,
Simon Glass77f57df2023-03-08 10:52:53 -0800302 warn_on_error=warn_on_error)
303 if type(add_maintainers) == type(cc):
304 cc += add_maintainers
305 elif add_maintainers:
Simon Glass5750cc22025-05-07 18:02:47 +0200306 fname = os.path.join(cwd or '', commit.patch)
307 cc += get_maintainer.get_maintainer(get_maintainer_script, fname)
Simon Glass77f57df2023-03-08 10:52:53 -0800308 all_skips |= set(cc) & set(settings.bounces)
309 cc = list(set(cc) - set(settings.bounces))
310 if limit is not None:
311 cc = cc[:limit]
312 return cc
313
Simon Glass1f975b92021-01-23 08:56:15 -0700314 def MakeCcFile(self, process_tags, cover_fname, warn_on_error,
Simon Glass5750cc22025-05-07 18:02:47 +0200315 add_maintainers, limit, get_maintainer_script, alias,
316 cwd=None):
Simon Glass26132882012-01-14 15:12:45 +0000317 """Make a cc file for us to use for per-commit Cc automation
318
Doug Anderson507e8e82012-12-03 14:40:42 +0000319 Also stores in self._generated_cc to make ShowActions() faster.
320
Simon Glass26132882012-01-14 15:12:45 +0000321 Args:
Simon Glass77f57df2023-03-08 10:52:53 -0800322 process_tags (bool): Process tags as if they were aliases
323 cover_fname (str): If non-None the name of the cover letter.
324 warn_on_error (bool): True to print a warning when an alias fails to
325 match, False to ignore it.
326 add_maintainers (bool or list of str): Either:
Simon Glassb712eed2017-05-29 15:31:29 -0600327 True/False to call the get_maintainers to CC maintainers
328 List of maintainers to include (for testing)
Simon Glass77f57df2023-03-08 10:52:53 -0800329 limit (int): Limit the length of the Cc list (None if no limit)
330 get_maintainer_script (str): The file name of the get_maintainer.pl
Maxim Cournoyer3ef23e92022-12-20 00:28:46 -0500331 script (or compatible).
Simon Glass9938b7b2025-04-07 22:51:46 +1200332 alias (dict): Alias dictionary
333 key: alias
334 value: list of aliases or email addresses
Simon Glass5750cc22025-05-07 18:02:47 +0200335 cwd (str): Path to use for patch filenames (None to use current dir)
Simon Glass26132882012-01-14 15:12:45 +0000336 Return:
337 Filename of temp file created
338 """
Chris Packhame8d2a122017-09-01 20:57:53 +1200339 col = terminal.Color()
Simon Glass26132882012-01-14 15:12:45 +0000340 # Look for commit tags (of the form 'xxx:' at the start of the subject)
341 fname = '/tmp/patman.%d' % os.getpid()
Simon Glassf544a2d2019-10-31 07:42:51 -0600342 fd = open(fname, 'w', encoding='utf-8')
Doug Anderson05416af2012-12-03 14:40:43 +0000343 all_ccs = []
Simon Glass77f57df2023-03-08 10:52:53 -0800344 all_skips = set()
Simon Glass620639c2023-03-08 10:52:54 -0800345 with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
346 for i, commit in enumerate(self.commits):
347 commit.seq = i
348 commit.future = executor.submit(
349 self.GetCcForCommit, commit, process_tags, warn_on_error,
Simon Glass9938b7b2025-04-07 22:51:46 +1200350 add_maintainers, limit, get_maintainer_script, all_skips,
Simon Glass5750cc22025-05-07 18:02:47 +0200351 alias, cwd)
Simon Glass620639c2023-03-08 10:52:54 -0800352
353 # Show progress any commits that are taking forever
354 lastlen = 0
355 while True:
356 left = [commit for commit in self.commits
357 if not commit.future.done()]
358 if not left:
359 break
360 names = ', '.join(f'{c.seq + 1}:{c.subject}'
361 for c in left[:2])
362 out = f'\r{len(left)} remaining: {names}'[:79]
363 spaces = ' ' * (lastlen - len(out))
364 if lastlen: # Don't print anything the first time
365 print(out, spaces, end='')
366 sys.stdout.flush()
367 lastlen = len(out)
368 time.sleep(.25)
369 print(f'\rdone{" " * lastlen}\r', end='')
370 print('Cc processing complete')
371
Simon Glass26132882012-01-14 15:12:45 +0000372 for commit in self.commits:
Simon Glass620639c2023-03-08 10:52:54 -0800373 cc = commit.future.result()
Simon Glass0f94fa72017-05-29 15:31:30 -0600374 all_ccs += cc
Dmitry Torokhovef7f67d2019-10-21 20:09:56 -0700375 print(commit.patch, '\0'.join(sorted(set(cc))), file=fd)
Simon Glass0f94fa72017-05-29 15:31:30 -0600376 self._generated_cc[commit.patch] = cc
Simon Glass26132882012-01-14 15:12:45 +0000377
Simon Glass77f57df2023-03-08 10:52:53 -0800378 for x in sorted(all_skips):
379 print(col.build(col.YELLOW, f'Skipping "{x}"'))
380
Doug Anderson05416af2012-12-03 14:40:43 +0000381 if cover_fname:
Simon Glassdea1ddf2025-04-07 22:51:44 +1200382 cover_cc = gitutil.build_email_list(
Simon Glass32f12a7e2025-04-07 22:51:47 +1200383 self.get('cover_cc', ''), alias)
Simon Glass39ed6bb2020-02-27 18:49:23 -0700384 cover_cc = list(set(cover_cc + all_ccs))
385 if limit is not None:
386 cover_cc = cover_cc[:limit]
Simon Glass9dfb3112020-11-08 20:36:18 -0700387 cc_list = '\0'.join([x for x in sorted(cover_cc)])
Robert Beckett3356f2c2019-11-13 18:39:45 +0000388 print(cover_fname, cc_list, file=fd)
Doug Anderson05416af2012-12-03 14:40:43 +0000389
Simon Glass26132882012-01-14 15:12:45 +0000390 fd.close()
391 return fname
392
393 def AddChange(self, version, commit, info):
394 """Add a new change line to a version.
395
396 This will later appear in the change log.
397
398 Args:
Simon Glass27d6f0f2025-05-08 06:35:42 +0200399 version (int): version number to add change list to
400 commit (Commit): Commit this relates to, or None if related to a
401 cover letter
402 info (str): change lines for this version (separated by \n)
Simon Glass26132882012-01-14 15:12:45 +0000403 """
404 if not self.changes.get(version):
405 self.changes[version] = []
406 self.changes[version].append([commit, info])
407
408 def GetPatchPrefix(self):
409 """Get the patch version string
410
411 Return:
412 Patch string, like 'RFC PATCH v5' or just 'PATCH'
413 """
Simon Glass761648b2022-01-29 14:14:11 -0700414 git_prefix = gitutil.get_default_subject_prefix()
Wu, Josh9873b912015-04-15 10:25:18 +0800415 if git_prefix:
Paul Burtona5edb442016-09-27 16:03:49 +0100416 git_prefix = '%s][' % git_prefix
Wu, Josh9873b912015-04-15 10:25:18 +0800417 else:
418 git_prefix = ''
419
Simon Glass26132882012-01-14 15:12:45 +0000420 version = ''
421 if self.get('version'):
422 version = ' v%s' % self['version']
423
424 # Get patch name prefix
425 prefix = ''
426 if self.get('prefix'):
427 prefix = '%s ' % self['prefix']
Sean Andersondc1cd132021-10-22 19:07:04 -0400428
429 postfix = ''
430 if self.get('postfix'):
431 postfix = ' %s' % self['postfix']
432 return '%s%sPATCH%s%s' % (git_prefix, prefix, postfix, version)