From patchwork Thu Jul 22 14:51:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Delaunay X-Patchwork-Id: 1508752 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector1 header.b=OjYYuToD; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GVwQR2tm7z9sW5 for ; Fri, 23 Jul 2021 00:51:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E58E482BC7; Thu, 22 Jul 2021 16:51:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foss.st.com header.i=@foss.st.com header.b="OjYYuToD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C326B82BDF; Thu, 22 Jul 2021 16:51:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0812C82BAA for ; Thu, 22 Jul 2021 16:51:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=1837f80f6a=patrick.delaunay@foss.st.com Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16MEhgvn027821; Thu, 22 Jul 2021 16:51:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=selector1; bh=EOr8ze4SkAHRaGTBRqUrGFzbXwyJtTZT254TqCg2oY4=; b=OjYYuToDqwYDbCGtaCajHIjzAWNP0a487sG+mf4xVZKj2EklmcJjnJz4QJZzJhBgrfGL S07pNLdnakvSk6nbW5TWygu5/x0IMTixVP/e08lwEhsIrj0hpjAg5SFZkOIHXthJbal7 nPTmv8x9bWuChIQAyNQ02vzkD19p2R9Q7vOHU0zJzRglyxwXIoxO3mjkJ8fqDnMqxoc9 b33TRvDbyVvn+Zi1WdyNo1Qo4BOsRfmuPllB93z5bq7+g7TgSmyuuEWZbt0hpCmrpa3j akpSyXxXV9+kOkQBn5m6zKZFJIRg67k/OAuNM+6SpWXLy2ZxbhIKTQPuhmyeEFagCRYx hg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 39y43wtbqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Jul 2021 16:51:44 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3DE7E10002A; Thu, 22 Jul 2021 16:51:44 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 330AD226FBF; Thu, 22 Jul 2021 16:51:44 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 22 Jul 2021 16:51:43 +0200 From: Patrick Delaunay To: CC: Patrick Delaunay , Simon Glass , U-Boot STM32 Subject: [PATCH v2] patman: add warning for invalid tag Date: Thu, 22 Jul 2021 16:51:42 +0200 Message-ID: <20210722165101.v2.1.I6630d4cc18870d3e830587ffbcb61898dc045cb6@changeid> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-22_09:2021-07-22, 2021-07-22 signatures=0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Add a error in patman tool when the commit message contents an invalid tag "Serie-.*" instead of "Series-.*". Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- I create this patch to avoid my frequent mistake: using "Serie-" tag instead of "Series-" as it is done in [1]. RE_INV_TAG can be extended to other frequent errors. Any "Serie-" tag is refused with the patch, for example: ValueError: Line 28: Invalid tag = 'Serie-cc: Marek BehĂșn ' [1] http://patchwork.ozlabs.org/project/uboot/patch/20210720203353.1.I550b95f6d12d59aeef5b744d837dbb360037d39e@changeid/ Changes in v2: - add patman test testInvalidTag tools/patman/func_test.py | 11 +++++++++++ tools/patman/patchstream.py | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 1ce6448d00..9871bb580d 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -506,6 +506,17 @@ Tested-by: %s 'Reviewed-by': {self.joe, self.mary}, 'Tested-by': {self.leb}}) + def testInvalidTag(self): + """Test invalid tag in a patchstream""" + text = '''This is a patch + +Serie-version: 2 +''' + with self.assertRaises(ValueError) as exc: + pstrm = PatchStream.process_text(text) + self.assertEqual("Line 3: Invalid tag = 'Serie-version: 2'", + str(exc.exception)) + def testMissingEnd(self): """Test a missing END tag""" text = '''This is a patch diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index a44cd861af..b960292427 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -59,6 +59,9 @@ RE_DIFF = re.compile(r'^>.*diff --git a/(.*) b/(.*)$') # Detect a context line, like '> @@ -153,8 +153,13 @@ CheckPatch RE_LINE = re.compile(r'>.*@@ \-(\d+),\d+ \+(\d+),\d+ @@ *(.*)') +# Detect line with invalid TAG +RE_INV_TAG = re.compile('^Serie-([a-z-]*): *(.*)') + # States we can be in - can we use range() and still have comments? STATE_MSG_HEADER = 0 # Still in the message header STATE_PATCH_SUBJECT = 1 # In patch subject (first line of log for a commit) @@ -318,6 +321,7 @@ class PatchStream: leading_whitespace_match = RE_LEADING_WHITESPACE.match(line) diff_match = RE_DIFF.match(line) line_match = RE_LINE.match(line) + invalid_match = RE_INV_TAG.match(line) tag_match = None if self.state == STATE_PATCH_HEADER: tag_match = RE_TAG.match(line) @@ -471,6 +475,11 @@ class PatchStream: self._add_warn('Line %d: Ignoring Commit-%s' % (self.linenum, name)) + # Detect invalid tags + elif invalid_match: + raise ValueError("Line %d: Invalid tag = '%s'" % + (self.linenum, line)) + # Detect the start of a new commit elif commit_match: self._close_commit()