All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] patman: Avoid blank lines between tags
@ 2021-08-01 22:02 Simon Glass
  2021-08-09  2:31 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Glass @ 2021-08-01 22:02 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Bin Meng, Simon Glass

In some cases 'patman status' leaves a blank line between the sign-off
and the tags it collects from patchwork. Fix this and add a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/patman/func_test.py   | 23 ++++++++++++++++++++++-
 tools/patman/patchstream.py |  7 ++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 9871bb580d0..2493e527f52 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -136,7 +136,7 @@ class TestFunctional(unittest.TestCase):
             Commit-changes: 2
             - Changes only for this commit
 
-            Cover-changes: 4
+'            Cover-changes: 4
             - Some notes for the cover letter
 
             Cover-letter:
@@ -1293,3 +1293,24 @@ Reviewed-by: %s
         self.assertEqual(terminal.PrintLine(
             '4 new responses available in patchwork (use -d to write them to a new branch)',
             None), next(lines))
+
+    def testInsertTags(self):
+        """Test inserting of review tags"""
+        msg = '''first line
+second line.'''
+        tags = [
+            'Reviewed-by: Bin Meng <bmeng.cn@gmail.com>',
+            'Tested-by: Bin Meng <bmeng.cn@gmail.com>'
+            ]
+        signoff = 'Signed-off-by: Simon Glass <sjg@chromium.com>'
+        tag_str = '\n'.join(tags)
+
+        new_msg = patchstream.insert_tags(msg, tags)
+        self.assertEqual(msg + '\n\n' + tag_str, new_msg)
+
+        new_msg = patchstream.insert_tags(msg + '\n', tags)
+        self.assertEqual(msg + '\n\n' + tag_str, new_msg)
+
+        msg += '\n\n' + signoff
+        new_msg = patchstream.insert_tags(msg, tags)
+        self.assertEqual(msg + '\n' + tag_str, new_msg)
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index b9602924273..2439fb18e42 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -662,6 +662,7 @@ def insert_tags(msg, tags_to_emit):
     out = []
     done = False
     emit_tags = False
+    emit_blank = False
     for line in msg.splitlines():
         if not done:
             signoff_match = RE_SIGNOFF.match(line)
@@ -672,9 +673,13 @@ def insert_tags(msg, tags_to_emit):
                 out += tags_to_emit
                 emit_tags = False
                 done = True
+            emit_blank = not (signoff_match or tag_match)
+        else:
+            emit_blank = line
         out.append(line)
     if not done:
-        out.append('')
+        if emit_blank:
+            out.append('')
         out += tags_to_emit
     return '\n'.join(out)
 
-- 
2.32.0.554.ge1b32706d8-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] patman: Avoid blank lines between tags
  2021-08-01 22:02 [PATCH] patman: Avoid blank lines between tags Simon Glass
@ 2021-08-09  2:31 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2021-08-09  2:31 UTC (permalink / raw)
  To: Simon Glass; +Cc: Bin Meng, U-Boot Mailing List

In some cases 'patman status' leaves a blank line between the sign-off
and the tags it collects from patchwork. Fix this and add a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/patman/func_test.py   | 23 ++++++++++++++++++++++-
 tools/patman/patchstream.py |  7 ++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-09  2:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-01 22:02 [PATCH] patman: Avoid blank lines between tags Simon Glass
2021-08-09  2:31 ` Simon Glass

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.