From 51cc17b9ed0ff06916c4f88405b9bc0aec0a7b27 Mon Sep 17 00:00:00 2001 From: Oleg Ananiev Date: Mon, 22 Jan 2024 16:05:23 +0000 Subject: [PATCH] utils.py: fix yaml output Fixes bug: https://github.com/getpatchwork/git-pw/issues/70 with incorrect output for 'Patches' property in .yaml format. Signed-off-by: Oleg Ananiev --- git_pw/utils.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/git_pw/utils.py b/git_pw/utils.py index c94758b..30071d4 100644 --- a/git_pw/utils.py +++ b/git_pw/utils.py @@ -94,6 +94,23 @@ def _tabulate( writer.writerow([ensure_str(i) for i in item]) return result.getvalue() elif fmt == 'yaml': + + tempout = [] + patch = () + for entry in output: + + if entry[0] == 'Patches': + l1 = [entry[1]] + patch = ('Patches',l1) + + elif len(patch) != 0 and entry[0] == '': + elem = entry[1] + patch[1].append(elem) + else: + tempout.append(entry) + output = tempout + output.append(patch) + data = [ {headers[i].lower(): entry[i] for i in range(len(headers))} for entry in output