From 3533746dbc73f9086e8f721b930f8bd951b4f63a Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 22 Aug 2023 18:12:36 -0700 Subject: [PATCH] trim off comment text that shouldn't be in MOU --- src/budget_sync/main.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/budget_sync/main.py b/src/budget_sync/main.py index 35a480e..15405ca 100644 --- a/src/budget_sync/main.py +++ b/src/budget_sync/main.py @@ -152,7 +152,6 @@ def summarize_milestones(budget_graph: BudgetGraph): print() - def json_milestones(budget_graph: BudgetGraph, add_comments: bool, output_dir: Path): """reports milestones as json format @@ -222,8 +221,26 @@ def json_milestones(budget_graph: BudgetGraph, add_comments: bool, intro = [] comment = "%s\n " % child.bug_url if add_comments: + comment += "\n" comments = bug_comments_map[str(child.bug.id)]['comments'] - comment += "\n%s" % comments[0]['text'] + lines = comments[0]['text'].splitlines() + for i, line in enumerate(lines): + # look for a line with only 4 or more `-` and blank lines + # before and after, like so: + # ``` + # + # ----- + # + # ``` + if len(line) >= 4 and line == "-" * len(line) \ + and i >= 1 and lines[i - 1] == "" and ( + i > len(lines) or lines[i + 1] == ""): + lines[i:] = [] + break + if line == "": + lines[i:] = [] + break + comment += "\n".join(lines) intro.append(comment) # print (description, intro) # sys.stdout.flush() -- 2.30.2