diff options
author | Simon Glass <sjg@chromium.org> | 2021-08-01 16:02:39 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-08-08 11:27:27 -0600 |
commit | 5974718752d80d3772bd0ef45630ba4ea8c2eb64 (patch) | |
tree | fcd50021f27193b7be3b6b802d229da78f048145 /tools | |
parent | 1e9ced28f18ed75bef96df08e47baad27dd51829 (diff) | |
download | u-boot-5974718752d80d3772bd0ef45630ba4ea8c2eb64.zip u-boot-5974718752d80d3772bd0ef45630ba4ea8c2eb64.tar.gz u-boot-5974718752d80d3772bd0ef45630ba4ea8c2eb64.tar.bz2 |
patman: Avoid blank lines between tags
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/patman/func_test.py | 23 | ||||
-rw-r--r-- | 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 9871bb5..2493e52 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 b960292..2439fb1 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) |