aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-23 13:58:04 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-23 13:58:04 -0400
commitf0074dfd57dc6238c730b462cdda6d048eaabbd3 (patch)
tree671b6bf3916fe5591f93aec06a0a24cfd180c2cb
parentf168ac9ac958a60e3c8fd656649939061f617501 (diff)
downloadb4-f0074dfd57dc6238c730b462cdda6d048eaabbd3.tar.gz
Use more unique mbx names by adding subjects
When the same person sends multiple sets of patches on the same day, we risk colliding between them. Use mbx names with cover/1st-patch subjects in them, to help disambiguate in such cases. Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/__init__.py12
-rw-r--r--b4/mbox.py8
2 files changed, 14 insertions, 6 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index 467da13..ee5f1dc 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -337,7 +337,7 @@ class LoreSeries:
self.patches[lmsg.counter] = lmsg
self.complete = not (None in self.patches[1:])
- def get_slug(self):
+ def get_slug(self, extended=False):
# Find the first non-None entry
lmsg = None
for lmsg in self.patches:
@@ -349,8 +349,14 @@ class LoreSeries:
prefix = lmsg.date.strftime('%Y%m%d')
authorline = email.utils.getaddresses(lmsg.msg.get_all('from', []))[0]
- author = re.sub(r'\W+', '_', authorline[1]).strip('_').lower()
- slug = '%s_%s' % (prefix, author)
+ if extended:
+ local = authorline[1].split('@')[0]
+ unsafe = '%s_%s_%s' % (prefix, local, lmsg.subject)
+ slug = re.sub(r'\W+', '_', unsafe).strip('_').lower()
+ else:
+ author = re.sub(r'\W+', '_', authorline[1]).strip('_').lower()
+ slug = '%s_%s' % (prefix, author)
+
if self.revision != 1:
slug = 'v%s_%s' % (self.revision, slug)
diff --git a/b4/mbox.py b/b4/mbox.py
index f4ae178..bb18fc9 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -128,8 +128,10 @@ def mbox_to_am(mboxfile, config, cmdargs):
slug = wantname
if wantname.find('.') > -1:
slug = '.'.join(wantname.split('.')[:-1])
+ gitbranch = slug
else:
- slug = lser.get_slug()
+ slug = lser.get_slug(extended=True)
+ gitbranch = lser.get_slug(extended=False)
am_filename = os.path.join(outdir, '%s.mbx' % slug)
am_cover = os.path.join(outdir, '%s.cover' % slug)
@@ -193,11 +195,11 @@ def mbox_to_am(mboxfile, config, cmdargs):
if base_commit:
logger.critical(' Base: %s', base_commit)
- logger.critical(' git checkout -b %s %s', slug, base_commit)
+ logger.critical(' git checkout -b %s %s', gitbranch, base_commit)
logger.critical(' git am %s', am_filename)
else:
logger.critical(' Base: not found, sorry')
- logger.critical(' git checkout -b %s master', slug)
+ logger.critical(' git checkout -b %s master', gitbranch)
logger.critical(' git am %s', am_filename)
am_mbx.close()