From 5787cddc0bde4514cba96a360f89841e13d2e506 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Sat, 20 Sep 2008 10:30:05 +1000 Subject: [PATCH] [parser] Don't remove --- update lines We'd like to keep update lines in the patch comments, so change the signature-removal code to allow them to pass through. Also, add appropriate tests. Signed-off-by: Jeremy Kerr --- apps/patchwork/bin/parsemail.py | 3 ++- apps/patchwork/tests/patchparser.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/patchwork/bin/parsemail.py b/apps/patchwork/bin/parsemail.py index 1f21393..b0f1497 100755 --- a/apps/patchwork/bin/parsemail.py +++ b/apps/patchwork/bin/parsemail.py @@ -298,8 +298,9 @@ def clean_subject(subject, drop_prefixes = None): return subject -sig_re = re.compile('^(-{2,3} ?|_+)\n.*', re.S | re.M) +sig_re = re.compile('^(-- |_+)\n.*', re.S | re.M) def clean_content(str): + """ Try to remove signature (-- ) and list footer (_____) cruft """ str = sig_re.sub('', str) return str.strip() diff --git a/apps/patchwork/tests/patchparser.py b/apps/patchwork/tests/patchparser.py index 3b10ef5..2e207bf 100644 --- a/apps/patchwork/tests/patchparser.py +++ b/apps/patchwork/tests/patchparser.py @@ -102,3 +102,27 @@ class SignatureCommentTest(InlinePatchTest): '-- \nsig\n' + self.orig_patch) (self.patch, self.comment) = find_content(self.project, email) + +class ListFooterTest(InlinePatchTest): + patch_filename = '0001-add-line.patch' + test_comment = 'Test comment\nmore comment' + + def setUp(self): + self.orig_patch = self.read_patch(self.patch_filename) + email = self.create_email( \ + self.test_comment + '\n' + \ + '_______________________________________________\n' + \ + 'Linuxppc-dev mailing list\n' + \ + self.orig_patch) + (self.patch, self.comment) = find_content(self.project, email) + + +class UpdateCommentTest(InlinePatchTest): + """ Test for '---\nUpdate: v2' style comments to patches. """ + patch_filename = '0001-add-line.patch' + test_comment = 'Test comment\nmore comment\n---\nUpdate: test update' + +class UpdateSigCommentTest(SignatureCommentTest): + """ Test for '---\nUpdate: v2' style comments to patches, with a sig """ + patch_filename = '0001-add-line.patch' + test_comment = 'Test comment\nmore comment\n---\nUpdate: test update' -- 2.39.2