All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kyle Meyer" <kyle@kyleam.com>
To: tools@linux.kernel.org
Subject: [PATCH b4 2/2] Fix handling of single-paragraph commit message bodies
Date: Sat, 25 Jul 2020 23:41:15 -0400	[thread overview]
Message-ID: <20200726034115.21567-3-kyle@kyleam.com> (raw)
In-Reply-To: <20200726034115.21567-1-kyle@kyleam.com>

The get_body_parts() method added in ba6c790 (Parse body parts into
usual chunks, 2020-04-27) strips lines that look like trailers from
the last paragraph, storing the other lines to add back to the
message.  However, if the commit message has only a single paragraph,
get_body_parts() returns early, unconditionally returning an empty
string for the message even if non-trailer lines were encountered.

Return the collected non-trailer lines, if any, as the message.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
---
 b4/__init__.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/b4/__init__.py b/b4/__init__.py
index 7e3134f..b7b33f4 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -1241,6 +1241,8 @@ def get_body_parts(body):
             if githeaders == trailers:
                 # This is a message that consists of just trailers?
                 githeaders = list()
+            if nlines:
+                message = '\n'.join(nlines)
             return githeaders, message, trailers, basement, signature
 
         # Add all parts between first and last to mparts
-- 
2.27.0


  parent reply	other threads:[~2020-07-26  3:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-26  3:41 [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() kyle
2020-07-26  3:41 ` [PATCH b4 1/2] Fix basement detection for empty commit message bodies Kyle Meyer
2020-07-26  3:41 ` Kyle Meyer [this message]
2020-07-27 14:08 ` [tools] [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() Konstantin Ryabitsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200726034115.21567-3-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=tools@linux.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.