From: Jacob Lifshay Date: Wed, 23 Aug 2023 01:12:36 +0000 (-0700) Subject: trim off comment text that shouldn't be in MOU X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3533746dbc73f9086e8f721b930f8bd951b4f63a;p=utils.git trim off comment text that shouldn't be in MOU --- 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()