From patchwork Tue Jul 11 13:39:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18806 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AAEA5C3243 for ; Tue, 11 Jul 2023 13:39:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E5D82628C7; Tue, 11 Jul 2023 15:39:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1689082762; bh=NcyCkiLhkOsMM7/Czz7Q19u8pchZ6gml5HMwcIfkcxw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vNF8Bms0M2HMig1z9imQv/h2V9Ujdq5kcEWfsK2AQyJqHS2I5LXXomacCKDLx/r+U 2Ewx/m7DnzzNFHka64nqVhEW6BaS16BDy2Bp+hA5t2KFsPnStcFF5mMKob9x9jjBfO lSaUcCWPLbeMj2nWFcoGHQJmuFMUgLyy067nimiI0dfIYWiALK4RGstRsbDzVRgTQZ PstHKkFa6jse3iPDe0BGdgvIg8mrs4YZ63lKJpYqoH+6cu/YduFe2R81OkzsRPvLKt 5OjTm//2GloPkb9hsi9qRBn5L4RG3cx/ZDgUI3eSxt5+XOM7g38E61R753ul+/gESJ v3ClNPjt/uAwA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6AEF861E32 for ; Tue, 11 Jul 2023 15:39:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="R/eVzJi/"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69EFF9B9; Tue, 11 Jul 2023 15:38:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1689082711; bh=NcyCkiLhkOsMM7/Czz7Q19u8pchZ6gml5HMwcIfkcxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/eVzJi/QzQ6urHl2NFDeisj6P2rQlViluwuZdhB/Shlkwn7DMOQAybDpXezP79NG +ry7JXf18pfOTQU2xCnIlU4Zxz7GGPktVIp1ywDsA7i+7NJNWdFgeIREckcZMKw8Sb 5NqQC006XAWCIaWs+pqBZEzlUGw1X25SDUhXj56k= To: libcamera devel Date: Tue, 11 Jul 2023 14:39:12 +0100 Message-Id: <20230711133915.650485-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711133915.650485-1-kieran.bingham@ideasonboard.com> References: <20230711133915.650485-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] utils: checkstyle.py: Treat Malformed trailers as a CommitIssue X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If a Malformed trailer is identified the checkstyle script triggers a RuntimeError and stops processing the rest of the commit. A malformed trailer can be regarded as an issue in the commit and reported as such using the same method as other faults identified by the tool. Convert the RuntimeError into a CommitIssue and continue processing other trailers. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain --- utils/checkstyle.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 3558740d389d..5a1268064d31 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -479,7 +479,8 @@ class TrailersChecker(CommitChecker): for trailer in commit.trailers: match = TrailersChecker.trailer_regex.fullmatch(trailer) if not match: - raise RuntimeError(f"Malformed commit trailer '{trailer}'") + issues.append(CommitIssue(f"Malformed commit trailer '{trailer}'")) + continue key, value = match.groups() From patchwork Tue Jul 11 13:39:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18807 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 661C9BDC71 for ; Tue, 11 Jul 2023 13:39:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5BDD2628C4; Tue, 11 Jul 2023 15:39:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1689082763; bh=dwGTKB4Xdctx/L/3EVlsU8sd8d0ACNj3Q86W2ydualk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=kRuEbfGguisfLmfhXvYjUFeY7EtYobVwtvkx3N0hkONSBsVW9FNBnVitciWlYXoTA uTEIMAWD7vEUZ/V9Hx8a+Yqr7DodLtpRTlbTGfp+eLtHhhLNyaTRKv8G2TNAZ4uCFz xwzru7KyhnvnzvXL91LAG44OgIeS+/jSJT33CDH9Kl6pCot8uJ+0R5af+NUenAngQ2 JDPIJqOVx/NZKpwPxw1XlhPgx8VcV7uPzd3PgJXBiOa7x3dg1+d5EDWlF9DDAj7PyN KdkIbpQyRtTNc5Z9VWe5OuTP7J90jL9iSfcDXNGt7P3ACTZrTpRUvqI/Bh9W5HCcVJ PwAwWFqfxNQoQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CC09628BD for ; Tue, 11 Jul 2023 15:39:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BYt5s24O"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B1DCBDC9; Tue, 11 Jul 2023 15:38:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1689082711; bh=dwGTKB4Xdctx/L/3EVlsU8sd8d0ACNj3Q86W2ydualk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BYt5s24ObadzwqeTt6jyH9bwyY6aDNFqUk9MEV6/RF+GM7kVqFC8poGoc6wccoiQk 3K49H+Wb8LnO3fVe9wLCIoP+shz5z8Yb3m5Mgx5tLZfGMhurAeEv6Evm06cbnQZEfi JJX1f6oy7/A76aseNsjKkou3mR3abMQmdEgqgINU= To: libcamera devel Date: Tue, 11 Jul 2023 14:39:13 +0100 Message-Id: <20230711133915.650485-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711133915.650485-1-kieran.bingham@ideasonboard.com> References: <20230711133915.650485-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] utils: checkstyle.py: Initialise staged trailers X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There are no possible Trailers for staged changes as the commit message has not yet been written. Initialise the empty trailers when the commit object is initialised. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain --- utils/checkstyle.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 5a1268064d31..2ba3165b8ecd 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -253,6 +253,9 @@ class StagedChanges(Commit): def __init__(self): Commit.__init__(self, '') + # There are no trailers to parse on a Staged Change. + self._trailers = [] + def _parse(self): ret = subprocess.run(['git', 'diff', '--staged', '--name-status'], stdout=subprocess.PIPE).stdout.decode('utf-8') From patchwork Tue Jul 11 13:39:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18808 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CB706C32AA for ; Tue, 11 Jul 2023 13:39:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B60A628C0; Tue, 11 Jul 2023 15:39:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1689082764; bh=FnsDFbhbH5fHvsvlfP3Vh11bJ9n/j776hWcPzDBcxcU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vTNn6pJD3CTzH7/zVWhuV81s9/gjDdQP26ge2n/fb4aKy8p9zSWT2PVDoZvnBFGIk LKxNeAQhe2UKjmnZE/KnAIVQeg7/O0y3NLXR57zNE35JOtj/SyYTjiOp3KHxV7uR1L Q92N/ukYZMI//5UHOivWhGH7aJPajd8OMdbR5+ViIH/leR3Scr08wUQH8ntpi4pdVk o6oo7R/FY27B/uNSVls4jbIEsNP5aiudgfDmwhTI4Cov0HSeTwk8GApaJM42rswwEU pBV7BWjsOKkyiI3qY/M2AJ+p2Ylwm+fdzhF5spzN1NSRPpaK+F95fVVBckbxspiPLM vJi5jXwGD4b8A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D435460570 for ; Tue, 11 Jul 2023 15:39:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kQTibisf"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 06C3F8CC; Tue, 11 Jul 2023 15:38:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1689082712; bh=FnsDFbhbH5fHvsvlfP3Vh11bJ9n/j776hWcPzDBcxcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQTibisfP767fMqlyo55lKLDZ0/Zt76jEc11rVTbCJHXdq4HTOYQRIqQLH+SOkZO1 J3Shm2uY6h46P4U8AWIuqJdNzbOAFeZ84FQ3WmmoB20tFuS+aANhfq+7isOdTuKyXM 5ZvpCLK18Bnp3EqyDRQ7ILOkbrPCsaeNeiQoCsAM= To: libcamera devel Date: Tue, 11 Jul 2023 14:39:14 +0100 Message-Id: <20230711133915.650485-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711133915.650485-1-kieran.bingham@ideasonboard.com> References: <20230711133915.650485-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] utils: checkstyle.py: Derive Amendment from Commit X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The Amendment commit class is derived from the StagedChanges class (which in turn derives from the Commit base class), however there is no code sharing between Amendment and StagedChanges other than the call to initalise through the base Commit class. Refactor the inheritance to make an Amendment derive directly from Commit. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain --- utils/checkstyle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 2ba3165b8ecd..5663af811961 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -269,9 +269,9 @@ class StagedChanges(Commit): return parse_diff(diff.splitlines(True)) -class Amendment(StagedChanges): +class Amendment(Commit): def __init__(self): - StagedChanges.__init__(self) + Commit.__init__(self, '') def _parse(self): # Create a title using HEAD commit From patchwork Tue Jul 11 13:39:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18809 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1044DC32AB for ; Tue, 11 Jul 2023 13:39:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 89745628CD; Tue, 11 Jul 2023 15:39:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1689082764; bh=TRA2z1UJ6KXNTA4/vzT75gmTmgHKD5IvTMrfUMl6Rds=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=J862Gg8GH6aR5qhdktODjf4J6k/xiqZKGZIWzTvixecc9pwUKxEyQL1S5nbbWGb1a ilVfoopnUFGb+cCYKog/296bku3HbCSHowHjBS7e6/tAhoExmNp/FB7r38OW27SA3o 5rPe1Xo93kjo0PLnmSAtHeZTBlaaW5AvJ0Dl8esbEGlwqiiBxfuc0ulEgdLgs4oVfa EOW/dRNCE4GtAg12jUxPWiGphtRwtGi7jpKvP7lsxF1vN7wkfjO06020EHtvmhKXbU NA9OBVP+N+OIgtlcx/oB504bfSHxR2ZIt66AFd0hSI+7+XP0aq4dAgJP5M5qy2tXt6 t6Xj9324K3lkA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BEDA628C2 for ; Tue, 11 Jul 2023 15:39:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GOCinDyn"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4C8669B9; Tue, 11 Jul 2023 15:38:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1689082712; bh=TRA2z1UJ6KXNTA4/vzT75gmTmgHKD5IvTMrfUMl6Rds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GOCinDyn3orzzcgIehyI/smAJgZFtINOWyah6KlL5WFjOXrt/yAXBtQqvYXzTCKdg NkYxUVvElmSGIYukZsn09XYzL/x4MeDPjEIG9h5v52VAO5wgMfGMf4M6t38+J/7evu a5duDwl+o56TCpGv7WexR5DqlfS0xiXJ8O3DXL4I= To: libcamera devel Date: Tue, 11 Jul 2023 14:39:15 +0100 Message-Id: <20230711133915.650485-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711133915.650485-1-kieran.bingham@ideasonboard.com> References: <20230711133915.650485-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] utils: checkstyle.py: Check trailers for Amendment commits X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The commit trailers are checked as part of processing the commit message with the newly introduced TrailersChecker. This relies on the trailers property being correctly exposed by the Commit object, and is implemented for the base Commit but not processed for Amendment commits. Refactor the trailer property handling to a helper function in the base Commit class and make use of it with a newly added call to obtain the existing Trailers from the most recent commit when using Amendment. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain --- utils/checkstyle.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 5663af811961..214509bc74d4 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -208,6 +208,17 @@ class Commit: self.commit = commit self._parse() + def _parse_trailers(self, lines): + self._trailers = [] + for index in range(1, len(lines)): + line = lines[index] + if not line: + break + + self._trailers.append(line) + + return index + def _parse(self): # Get the commit title and list of files. ret = subprocess.run(['git', 'show', '--format=%s%n%(trailers:only,unfold)', '--name-status', @@ -217,14 +228,7 @@ class Commit: self._title = lines[0] - self._trailers = [] - for index in range(1, len(lines)): - line = lines[index] - if not line: - break - - self._trailers.append(line) - + index = self._parse_trailers(lines) self._files = [CommitFile(f) for f in lines[index:] if f] def files(self, filter='AMR'): @@ -283,6 +287,12 @@ class Amendment(Commit): stdout=subprocess.PIPE).stdout.decode('utf-8') self._files = [CommitFile(f) for f in ret.splitlines()] + # Parse trailers from the existing commit only. + ret = subprocess.run(['git', 'show', '--format=%n%(trailers:only,unfold)', + '--no-patch'], + stdout=subprocess.PIPE).stdout.decode('utf-8') + self._parse_trailers(ret.splitlines()) + def get_diff(self, top_level, filename): diff = subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--', '%s/%s' % (top_level, filename)],