diff options
-rw-r--r-- | b4/__init__.py | 12 | ||||
-rw-r--r-- | b4/mbox.py | 8 |
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) @@ -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() |