From 349ae3620bce99e06f6988593391d32f212da627 Mon Sep 17 00:00:00 2001 From: alstr Date: Sun, 28 Mar 2021 12:18:13 +0100 Subject: [PATCH] Strip removed lines from code snippet --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index af12f33..1b0ece9 100644 --- a/main.py +++ b/main.py @@ -299,7 +299,11 @@ class TodoParser(object): # Strip some of the diff symbols so it can be included as a code snippet in the issue body. for i, issue in enumerate(issues): - cleaned_hunk = re.sub(r'^.', '', issue.hunk, 0, re.MULTILINE) + # Strip removed lines. + cleaned_hunk = re.sub(r'\n^-.*$', '', issue.hunk, 0, re.MULTILINE) + # Strip leading symbols/whitespace. + cleaned_hunk = re.sub(r'^.', '', cleaned_hunk, 0, re.MULTILINE) + # Strip newline message. cleaned_hunk = re.sub(r'\n\sNo newline at end of file', '', cleaned_hunk, 0, re.MULTILINE) issue.hunk = cleaned_hunk return issues