From patchwork Wed Aug 7 12:15:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20817 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 DC014BE173 for ; Wed, 7 Aug 2024 12:15:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A5C1633B1; Wed, 7 Aug 2024 14:15:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uzHIrQiX"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 262AC6337E for ; Wed, 7 Aug 2024 14:15:41 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 489B42EC for ; Wed, 7 Aug 2024 14:14:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1723032888; bh=N2CKPecvo37g2Ig/2RCWbU/wseqXUeUtU9rMVo3pM+0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uzHIrQiXEnPPBXE3yjxnBNAPwEgJA/KP+O3X1TS6VXDRu9/gEfffEibZ6aLt/FQLd KviD6nftJDEKpgMeM7+hieNO8NbUIDB8Nq488JeozNCGHggMLFSWp4YmwNktuGgHvm Ibb+6GrcJzGNHRXvPvuucpm8GO6vTHuDkniauB4w= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 1/3] utils: checkstyle.py: Add author property to Commit class Date: Wed, 7 Aug 2024 15:15:14 +0300 Message-ID: <20240807121516.13608-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240807121516.13608-1-laurent.pinchart@ideasonboard.com> References: <20240807121516.13608-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Extend the Commit class with an author property, retrieved from the commit. It will be used to extend checkers. While at it, drop the unneeded .strip() call when retrieving the title for amendment commits. The call got carried over from code that initially needed it to strip the new line character, but that need disappeard with usage of .splitlines(). Signed-off-by: Laurent Pinchart Reviewed-by: Stefan Klug Reviewed-by: Kieran Bingham --- Changes since v1: - Wrap long line - Drop .strip() - Initialize _author to None --- utils/checkstyle.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 7d480bdf4a2f..e8451846c0c2 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -212,11 +212,12 @@ class CommitFile: class Commit: def __init__(self, commit): self.commit = commit + self._author = None self._trailers = [] self._parse() def _parse_trailers(self, lines): - for index in range(1, len(lines)): + for index in range(2, len(lines)): line = lines[index] if not line: break @@ -227,12 +228,13 @@ class Commit: def _parse(self): # Get the commit title and list of files. - ret = subprocess.run(['git', 'show', '--format=%s%n%(trailers:only,unfold)', '--name-status', - self.commit], + ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%s%n%(trailers:only,unfold)', + '--name-status', self.commit], stdout=subprocess.PIPE).stdout.decode('utf-8') lines = ret.splitlines() - self._title = lines[0] + self._author = lines[0] + self._title = lines[1] index = self._parse_trailers(lines) self._files = [CommitFile(f) for f in lines[index:] if f] @@ -240,6 +242,10 @@ class Commit: def files(self, filter='AMR'): return [f.filename for f in self._files if f.status in filter] + @property + def author(self): + return self._author + @property def title(self): return self._title @@ -282,12 +288,13 @@ class Amendment(Commit): def _parse(self): # Create a title using HEAD commit and parse the trailers. - ret = subprocess.run(['git', 'show', '--format=%H %s%n%(trailers:only,unfold)', + ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%H %s%n%(trailers:only,unfold)', '--no-patch'], stdout=subprocess.PIPE).stdout.decode('utf-8') lines = ret.splitlines() - self._title = 'Amendment of ' + lines[0].strip() + self._author = lines[0] + self._title = 'Amendment of ' + lines[1] self._parse_trailers(lines) From patchwork Wed Aug 7 12:15:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20818 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 49060BE173 for ; Wed, 7 Aug 2024 12:15:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 84FC9633AC; Wed, 7 Aug 2024 14:15:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="i3NMd4+O"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 91C6463382 for ; Wed, 7 Aug 2024 14:15:42 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A928C2EC for ; Wed, 7 Aug 2024 14:14:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1723032889; bh=e4NiVPk/ydUmg51/rtVAR8NFaiyyxvy5h6QbQWAr5uc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=i3NMd4+OUy5qjNyERQ0nD91IWJTu8JWvhwy8/kZZq6aNLfdZLVQkcDN0gd0pXAYlB P2/qNvLxuYnNBzwQNmMTV8Evd4JCNSgmhav6MKU942QOJBHT4aVHdQ0RmdcGbb+vc7 jMJ5prnZIsJdwWqONjBmv3C4UXJNb79jotT2WeLw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 2/3] utils: checkstyle.py: Validate SoB trailer against author Date: Wed, 7 Aug 2024 15:15:15 +0300 Message-ID: <20240807121516.13608-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240807121516.13608-1-laurent.pinchart@ideasonboard.com> References: <20240807121516.13608-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The TrailersChecker enforces the presence of a Signed-off-by tag in the trailer, but doesn't verify that the tag matches the commit's author. Add that verification, as required by the libcamera contribution process. Signed-off-by: Laurent Pinchart Reviewed-by: Stefan Klug Reviewed-by: Kieran Bingham --- utils/checkstyle.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index e8451846c0c2..560a2c1e8c58 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -525,10 +525,11 @@ class TrailersChecker(CommitChecker): continue if key == 'Signed-off-by': - sob_found = True + if value == commit.author: + sob_found = True if not sob_found: - issues.append(CommitIssue(f"No valid 'Signed-off-by' trailer found, see Documentation/contributing.rst")) + issues.append(CommitIssue(f"No 'Signed-off-by' trailer matching author '{commit.author}', see Documentation/contributing.rst")) return issues From patchwork Wed Aug 7 12:15:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20819 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 5B180BE173 for ; Wed, 7 Aug 2024 12:15:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E023663394; Wed, 7 Aug 2024 14:15:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="US0EgPQT"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1537463394 for ; Wed, 7 Aug 2024 14:15:44 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2AD9A96C for ; Wed, 7 Aug 2024 14:14:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1723032891; bh=IuJ0yCW+peWoerrN/voMkeXiPtFYVGltBzzgK0/Qx6o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=US0EgPQTvSxBL/dQLtNO01zih0IBLmtyuR7LHVIFr3mOr645jcOt63qjvbPPpgT+A xy8yUEIrEX3lVhUz4t0q/nEZwikwj3Tf9Y+qKDwP+gs0DZDdT1K0QK2Tqaj8Wf09mW dZ02IUR4mq/3EaVBEzQCKQ0QZ0ib35bNsAvMgVok= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 3/3] utils: checkstyle.py: Fix trailer parsing for commits with changelogs Date: Wed, 7 Aug 2024 15:15:16 +0300 Message-ID: <20240807121516.13608-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240807121516.13608-1-laurent.pinchart@ideasonboard.com> References: <20240807121516.13608-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Trailers are extracted from commits using the '(trailers:*)' formatting specifier. git ignores dividers when doing so, as if the --no-divider options was passed to git-interpret-trailers. This prevents trailers from being located when the patch contains a local changelog. There is unfortuantely no 'no-no-divider' option to the trailers format specifier. Fix the issue by extracting trailers with git-interpret-trailers, that gives better control of the parsing. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- utils/checkstyle.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 560a2c1e8c58..dae5d518920a 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -216,28 +216,28 @@ class Commit: self._trailers = [] self._parse() - def _parse_trailers(self, lines): - for index in range(2, len(lines)): - line = lines[index] - if not line: - break + def _parse_trailers(self): + proc_show = subprocess.run(['git', 'show', '--format=%b', + '--no-patch', self.commit], + stdout=subprocess.PIPE) + trailers = subprocess.run(['git', 'interpret-trailers', '--parse'], + input=proc_show.stdout, + stdout=subprocess.PIPE).stdout.decode('utf-8') - self._trailers.append(line) - - return index + self._trailers = trailers.splitlines() def _parse(self): # Get the commit title and list of files. - ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%s%n%(trailers:only,unfold)', + ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%s', '--name-status', self.commit], stdout=subprocess.PIPE).stdout.decode('utf-8') lines = ret.splitlines() self._author = lines[0] self._title = lines[1] + self._files = [CommitFile(f) for f in lines[2:] if f] - index = self._parse_trailers(lines) - self._files = [CommitFile(f) for f in lines[index:] if f] + self._parse_trailers() def files(self, filter='AMR'): return [f.filename for f in self._files if f.status in filter] @@ -288,7 +288,7 @@ class Amendment(Commit): def _parse(self): # Create a title using HEAD commit and parse the trailers. - ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%H %s%n%(trailers:only,unfold)', + ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%H %s', '--no-patch'], stdout=subprocess.PIPE).stdout.decode('utf-8') lines = ret.splitlines() @@ -296,7 +296,7 @@ class Amendment(Commit): self._author = lines[0] self._title = 'Amendment of ' + lines[1] - self._parse_trailers(lines) + self._parse_trailers() # Extract the list of modified files ret = subprocess.run(['git', 'diff', '--staged', '--name-status', 'HEAD~'],