From c4469dc30c30f629b1d725b663d80e8a78956c61 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Wed, 15 Apr 2020 13:56:13 -0400 Subject: Keep track of how many messages we create Don't tell us to run git send-email when there's nothing to send. Signed-off-by: Konstantin Ryabitsev --- b4/ty.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/b4/ty.py b/b4/ty.py index 4b69f5c..0592af5 100644 --- a/b4/ty.py +++ b/b4/ty.py @@ -320,6 +320,7 @@ def send_messages(listing, gitdir, outdir, branch, since='1.week'): else: signature = '%s <%s>' % (usercfg['name'], usercfg['email']) + outgoing = 0 for jsondata in listing: slug_from = re.sub(r'\W', '_', jsondata['fromemail']) slug_subj = re.sub(r'\W', '_', jsondata['subject']) @@ -337,6 +338,8 @@ def send_messages(listing, gitdir, outdir, branch, since='1.week'): if msg is None: continue + + outgoing += 1 outfile = os.path.join(outdir, '%s.thanks' % slug) logger.info(' Writing: %s', outfile) bout = msg.as_string(policy=b4.emlpolicy) @@ -346,6 +349,11 @@ def send_messages(listing, gitdir, outdir, branch, since='1.week'): fullpath = os.path.join(datadir, jsondata['trackfile']) os.rename(fullpath, '%s.sent' % fullpath) logger.info('---') + if not outgoing: + logger.info('No thanks necessary.') + return + + logger.debug('Wrote %s thank-you letters', outgoing) logger.info('You can now run:') logger.info(' git send-email %s/*.thanks', outdir) -- cgit v1.2.3