patman: Add "postfix" support to patch subjects

In some communities, it may be necessary to append something after PATCH
in the subject line. For example, the Linux networking subsystem
expects [1] patch subject prefixes like [RFC PATCH net-next 0/99]. This
adds support for such "postfix"s to patman. Although entirely cosmetic,
it is still nice to have.

[1] https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Sean Anderson 2021-10-22 19:07:04 -04:00 committed by Simon Glass
parent 37f3758a25
commit 082c119af9
5 changed files with 19 additions and 4 deletions

View file

@ -188,6 +188,11 @@ Series-prefix: prefix
well. If your format.subjectprefix is set to InternalProject, then well. If your format.subjectprefix is set to InternalProject, then
the patch shows like: [InternalProject][RFC/RESEND PATCH] the patch shows like: [InternalProject][RFC/RESEND PATCH]
Series-postfix: postfix
Sets the subject "postfix". Normally empty, but can be the name of a
tree such as net or net-next if that needs to be specified. The patch
subject is like [PATCH net] or [PATCH net-next].
Series-name: name Series-name: name
Sets the name of the series. You don't need to have a name, and Sets the name of the series. You don't need to have a name, and
patman does not yet use it, but it is convenient to put the branch patman does not yet use it, but it is convenient to put the branch

View file

@ -122,6 +122,7 @@ class TestFunctional(unittest.TestCase):
Series-to: u-boot Series-to: u-boot
Series-prefix: RFC Series-prefix: RFC
Series-postfix: some-branch
Series-cc: Stefan Brüns <stefan.bruens@rwth-aachen.de> Series-cc: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Cover-letter-cc: Lord Mëlchett <clergy@palace.gov> Cover-letter-cc: Lord Mëlchett <clergy@palace.gov>
Series-version: 3 Series-version: 3
@ -176,7 +177,7 @@ class TestFunctional(unittest.TestCase):
- each patch has the correct subject - each patch has the correct subject
- dry-run information prints out correctly - dry-run information prints out correctly
- unicode is handled correctly - unicode is handled correctly
- Series-to, Series-cc, Series-prefix, Cover-letter - Series-to, Series-cc, Series-prefix, Series-postfix, Cover-letter
- Cover-letter-cc, Series-version, Series-changes, Series-notes - Cover-letter-cc, Series-version, Series-changes, Series-notes
- Commit-notes - Commit-notes
""" """
@ -235,6 +236,7 @@ class TestFunctional(unittest.TestCase):
self.assertEqual('Cc: %s' % stefan, next(lines)) self.assertEqual('Cc: %s' % stefan, next(lines))
self.assertEqual('Version: 3', next(lines)) self.assertEqual('Version: 3', next(lines))
self.assertEqual('Prefix:\t RFC', next(lines)) self.assertEqual('Prefix:\t RFC', next(lines))
self.assertEqual('Postfix:\t some-branch', next(lines))
self.assertEqual('Cover: 4 lines', next(lines)) self.assertEqual('Cover: 4 lines', next(lines))
self.assertEqual(' Cc: %s' % self.fred, next(lines)) self.assertEqual(' Cc: %s' % self.fred, next(lines))
self.assertEqual(' Cc: %s' % self.leb, self.assertEqual(' Cc: %s' % self.leb,
@ -285,7 +287,7 @@ Simon Glass (2):
''' '''
lines = open(cover_fname, encoding='utf-8').read().splitlines() lines = open(cover_fname, encoding='utf-8').read().splitlines()
self.assertEqual( self.assertEqual(
'Subject: [RFC PATCH v3 0/2] test: A test patch series', 'Subject: [RFC PATCH some-branch v3 0/2] test: A test patch series',
lines[3]) lines[3])
self.assertEqual(expected.splitlines(), lines[7:]) self.assertEqual(expected.splitlines(), lines[7:])

View file

@ -596,6 +596,8 @@ class PatchStream:
# These seem like they would be nice to include. # These seem like they would be nice to include.
if 'prefix' in self.series: if 'prefix' in self.series:
parts.append(self.series['prefix']) parts.append(self.series['prefix'])
if 'postfix' in self.series:
parts.append(self.serties['postfix'])
if 'version' in self.series: if 'version' in self.series:
parts.append("v%s" % self.series['version']) parts.append("v%s" % self.series['version'])

View file

@ -16,7 +16,7 @@ from patman import tools
# Series-xxx tags that we understand # Series-xxx tags that we understand
valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name', valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
'cover_cc', 'process_log', 'links', 'patchwork_url'] 'cover_cc', 'process_log', 'links', 'patchwork_url', 'postfix']
class Series(dict): class Series(dict):
"""Holds information about a patch series, including all tags. """Holds information about a patch series, including all tags.
@ -133,6 +133,7 @@ class Series(dict):
print('Cc:\t ', item) print('Cc:\t ', item)
print('Version: ', self.get('version')) print('Version: ', self.get('version'))
print('Prefix:\t ', self.get('prefix')) print('Prefix:\t ', self.get('prefix'))
print('Postfix:\t ', self.get('postfix'))
if self.cover: if self.cover:
print('Cover: %d lines' % len(self.cover)) print('Cover: %d lines' % len(self.cover))
cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) cover_cc = gitutil.BuildEmailList(self.get('cover_cc', ''))
@ -322,4 +323,8 @@ class Series(dict):
prefix = '' prefix = ''
if self.get('prefix'): if self.get('prefix'):
prefix = '%s ' % self['prefix'] prefix = '%s ' % self['prefix']
return '%s%sPATCH%s' % (git_prefix, prefix, version)
postfix = ''
if self.get('postfix'):
postfix = ' %s' % self['postfix']
return '%s%sPATCH%s%s' % (git_prefix, prefix, postfix, version)

View file

@ -44,6 +44,7 @@ Date: Sat Apr 15 15:39:08 2017 -0600
Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Series-to: u-boot Series-to: u-boot
Series-prefix: RFC Series-prefix: RFC
Series-postfix: some-branch
Series-cc: Stefan Brüns <stefan.bruens@rwth-aachen.de> Series-cc: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Cover-letter-cc: Lord Mëlchett <clergy@palace.gov> Cover-letter-cc: Lord Mëlchett <clergy@palace.gov>
Series-version: 3 Series-version: 3