From 3f06f6fb40b41813e946154d591f4d1f37b52f85 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Fri, 10 Apr 2020 15:05:40 -0400 Subject: Add summaries to default templates They are much more useful if b4.thanks-commit-url-mask is set, but even without them this will list all subjects and corresponding commit IDs. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'b4/__init__.py') diff --git a/b4/__init__.py b/b4/__init__.py index 54cc42b..a49f439 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -93,6 +93,12 @@ DEFAULT_CONFIG = { 'attestation-checkmarks': 'fancy', # How long to keep things in cache before expiring (minutes)? 'cache-expire': '10', + # Used when creating summaries for b4 ty + 'thanks-commit-url-mask': None, + # See thanks-pr-template.example + '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 # git-config for gpg.program, and if that's not set, # we'll use "gpg" and hope for the better @@ -1673,3 +1679,17 @@ def format_addrs(pairs): # Remove any quoted-printable header junk from the name addrs.add(email.utils.formataddr((LoreMessage.clean_header(pair[0]), LoreMessage.clean_header(pair[1])))) return ', '.join(addrs) + + +def make_quote(body, maxlines=5): + quotelines = list() + qcount = 0 + for line in body.split('\n'): + # Quote the first paragraph only and then [snip] if we quoted more than maxlines + if qcount > maxlines and (not len(line.strip()) or line.strip().find('---') == 0): + quotelines.append('> ') + quotelines.append('> [...]') + break + quotelines.append('> %s' % line.strip('\r\n')) + qcount += 1 + return '\n'.join(quotelines) -- cgit v1.2.3