trim off comment text that shouldn't be in MOU
authorJacob Lifshay <programmerjake@gmail.com>
Wed, 23 Aug 2023 01:12:36 +0000 (18:12 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Wed, 23 Aug 2023 01:12:36 +0000 (18:12 -0700)
src/budget_sync/main.py

index 35a480e80a6acb07f28b34bd5bfc0da1218e9d57..15405ca18b52b243f0c69a1262f93deddff566e1 100644 (file)
@@ -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 == "<From here down doesn't go in MOU>":
+                        lines[i:] = []
+                        break
+                comment += "\n".join(lines)
             intro.append(comment)
             # print (description, intro)
             # sys.stdout.flush()