From patchwork Tue Jan 24 23:57:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 1731478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=KZWVLaSu; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P1kZV3mbDz23h0 for ; Wed, 25 Jan 2023 11:03:29 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4P1kZS6Xwnz3c7C for ; Wed, 25 Jan 2023 11:03:28 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=KZWVLaSu; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=that.guru (client-ip=136.175.108.116; helo=mail-108-mta116.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=KZWVLaSu; dkim-atps=neutral X-Greylist: delayed 304 seconds by postgrey-1.36 at boromir; Wed, 25 Jan 2023 11:03:19 AEDT Received: from mail-108-mta116.mxroute.com (mail-108-mta116.mxroute.com [136.175.108.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4P1kZH2DBcz307T for ; Wed, 25 Jan 2023 11:03:18 +1100 (AEDT) Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta116.mxroute.com (ZoneMTA) with ESMTPSA id 185e637a7f9000011e.002 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Tue, 24 Jan 2023 23:58:05 +0000 X-Zone-Loop: 9c44b595cbbcae1ff00e7f357c56ab40d2dd29e19fa2 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To: From:Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=PxCvTWOZwFlJrQ9FSLK/CT1jydljDEb3ueOzMuv6qIY=; b=K ZWVLaSuE4OQ3LiMlhkvIJHtISGl2llCiTU+34w9K3gCrys3hrHfVP4pw99PN9ulDS6o2tcrjGI05h CYxIDCLTLHaCcXWDZPmwSLPvsbCDqUC+C6B3ZAD/Ay1ZXY2Ar0X1cpBskJ26gipinPGZSWxYsV4qr fxMxtTa2WYsQGyG5DY7b+YH0n1YDCHX5JZb6o9cY8Wo8Ki/UKsAXEkgIH3vZaD3vCz7NG2J/KKrZm Bx7ERM2sK1Mo5RoGe8olw7yVpILy9ooaUi5sJpWFiGuhmcCz3x7M7Dy/autmDVNDLW2VIO9k4WiJP HK+8AuyUMmaPNPinchO3i2JSt35plnHCQ==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH] Correctly append tags on patches without commit details Date: Tue, 24 Jan 2023 23:57:56 +0000 Message-Id: <20230124235756.146520-1-stephen@that.guru> MIME-Version: 1.0 X-Authenticated-Id: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: siddhesh@gotplt.org Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Only a commit summary (a.k.a. patch subject) is necessary in Git: we don't need details. The regex we were using to search for postscripts however assumed that there would be _something_ before the postscript, resulting in a newline. This wasn't the case. Correct this assumption by instead using 're.MULTILINE' and matching on '^' and '$' for newlines instead of '\n'. Signed-off-by: Stephen Finucane Closes: #516 Cc: siddhesh@gotplt.org --- patchwork/tests/views/test_utils.py | 23 +++++++++++++++++++++++ patchwork/views/utils.py | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git patchwork/tests/views/test_utils.py patchwork/tests/views/test_utils.py index 6b980f9d..8b795815 100644 --- patchwork/tests/views/test_utils.py +++ patchwork/tests/views/test_utils.py @@ -66,6 +66,29 @@ class MboxPatchResponseTest(TestCase): mbox = utils.patch_to_mbox(self.patch) self.assertIn('Acked-by: 1\nAcked-by: 2\n', mbox) + def test_bug_516(self): + """Test that tags are appended if a patch description is unset.""" + patch = create_patch( + content=( + '---\n' + ' manual/string.texi | 2 +-\n' + ' 1 file changed, 1 insertion(+), 1 deletion(-)' + ), + ) + create_patch_comment(patch=patch, content='Acked-by: 2\n') + + mbox = utils.patch_to_mbox(patch) + # the epilog comes after the tags + self.assertIn( + ( + 'Acked-by: 2\n' + '---\n' + ' manual/string.texi | 2 +-\n' + ' 1 file changed, 1 insertion(+), 1 deletion(-)\n' + ), + mbox, + ) + def _test_header_passthrough(self, header): patch = create_patch(headers=header + '\n') mbox = utils.patch_to_mbox(patch) diff --git patchwork/views/utils.py patchwork/views/utils.py index 1f7ee0da..91b2ef1b 100644 --- patchwork/views/utils.py +++ patchwork/views/utils.py @@ -48,7 +48,7 @@ def _submission_to_mbox(submission): """ is_patch = isinstance(submission, Patch) - postscript_re = re.compile('\n-{2,3} ?\n') + postscript_re = re.compile('^-{2,3} ?$', re.MULTILINE) body = '' if submission.content: @@ -71,7 +71,7 @@ def _submission_to_mbox(submission): body += comment.patch_responses if postscript: - body += '---\n' + postscript + '\n' + body += '---' + postscript + '\n' if is_patch and submission.diff: body += '\n' + submission.diff