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)],