From 86c28ca7944da7432afdeabe04cae8f02b311c38 Mon Sep 17 00:00:00 2001 From: Manorit Chawdhry Date: Tue, 5 Sep 2023 11:16:40 +0530 Subject: [PATCH] Fixes the subject prefix in the emails The subject prefix had been coming "after" the "[PATCH", fix that to come before the PATCH string. Signed-off-by: Manorit Chawdhry --- src/b4/__init__.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/b4/__init__.py b/src/b4/__init__.py index ed328ff..d6e5495 100644 --- a/src/b4/__init__.py +++ b/src/b4/__init__.py @@ -142,7 +142,7 @@ def _dkim_log_filter(record): 'thanks-pr-template': None, # See thanks-am-template.example 'thanks-am-template': None, - # If this is not set, we'll use what we find in + # If this is not set, we'll use what we find in # git-config for gpg.program, and if that's not set, # we'll use "gpg" and hope for the better 'gpgbin': None, @@ -2488,17 +2488,25 @@ def get_extra_prefixes(self, exclude: Optional[List[str]] = None) -> List[str]: def get_rebuilt_subject(self, eprefixes: Optional[List[str]] = None) -> str: _pfx = self.get_extra_prefixes() + version = '' + expected = '' if eprefixes: for _epfx in eprefixes: if _epfx not in _pfx: _pfx.append(_epfx) + + if len(_pfx) > 0: + # This is added to handle the extra space after + # subject prefixes + _pfx.append('') + if self.revision > 1: - _pfx.append(f'v{self.revision}') + version = f' v{self.revision}' if self.expected > 1: - _pfx.append('%s/%s' % (str(self.counter).zfill(len(str(self.expected))), self.expected)) + expected = ' %s/%s' % (str(self.counter).zfill(len(str(self.expected))), self.expected) - if len(_pfx): - return '[PATCH ' + ' '.join(_pfx) + '] ' + self.subject + if len(_pfx) or len(version) or len(expected): + return '[' + ' '.join(_pfx) + 'PATCH' + version + expected + '] ' + self.subject else: return f'[PATCH] {self.subject}'