[{"id":30671,"web_url":"https://patchwork.libcamera.org/comment/30671/","msgid":"<172303451364.1687952.4264584785377514806@ping.linuxembedded.co.uk>","date":"2024-08-07T12:41:53","subject":"Re: [PATCH v2 3/3] utils: checkstyle.py: Fix trailer parsing for\n\tcommits with changelogs","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-08-07 13:15:16)\n> Trailers are extracted from commits using the '(trailers:*)' formatting\n> specifier. git ignores dividers when doing so, as if the --no-divider\n> options was passed to git-interpret-trailers. This prevents trailers\n> from being located when the patch contains a local changelog.\n> \n> There is unfortuantely no 'no-no-divider' option to the trailers format\n> specifier. Fix the issue by extracting trailers with\n> git-interpret-trailers, that gives better control of the parsing.\n\nSounds good to me and in fact looks simpler in the implementation?\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  utils/checkstyle.py | 26 +++++++++++++-------------\n>  1 file changed, 13 insertions(+), 13 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 560a2c1e8c58..dae5d518920a 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -216,28 +216,28 @@ class Commit:\n>          self._trailers = []\n>          self._parse()\n>  \n> -    def _parse_trailers(self, lines):\n> -        for index in range(2, len(lines)):\n> -            line = lines[index]\n> -            if not line:\n> -                break\n> +    def _parse_trailers(self):\n> +        proc_show = subprocess.run(['git', 'show', '--format=%b',\n> +                                    '--no-patch', self.commit],\n> +                                   stdout=subprocess.PIPE)\n> +        trailers = subprocess.run(['git', 'interpret-trailers', '--parse'],\n> +                                  input=proc_show.stdout,\n> +                                  stdout=subprocess.PIPE).stdout.decode('utf-8')\n>  \n> -            self._trailers.append(line)\n> -\n> -        return index\n> +        self._trailers = trailers.splitlines()\n>  \n>      def _parse(self):\n>          # Get the commit title and list of files.\n> -        ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%s%n%(trailers:only,unfold)',\n> +        ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%s',\n>                                '--name-status', self.commit],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n>          lines = ret.splitlines()\n>  \n>          self._author = lines[0]\n>          self._title = lines[1]\n> +        self._files = [CommitFile(f) for f in lines[2:] if f]\n>  \n> -        index = self._parse_trailers(lines)\n> -        self._files = [CommitFile(f) for f in lines[index:] if f]\n> +        self._parse_trailers()\n>  \n>      def files(self, filter='AMR'):\n>          return [f.filename for f in self._files if f.status in filter]\n> @@ -288,7 +288,7 @@ class Amendment(Commit):\n>  \n>      def _parse(self):\n>          # Create a title using HEAD commit and parse the trailers.\n> -        ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%H %s%n%(trailers:only,unfold)',\n> +        ret = subprocess.run(['git', 'show', '--format=%an <%ae>%n%H %s',\n>                               '--no-patch'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n>          lines = ret.splitlines()\n> @@ -296,7 +296,7 @@ class Amendment(Commit):\n>          self._author = lines[0]\n>          self._title = 'Amendment of ' + lines[1]\n>  \n> -        self._parse_trailers(lines)\n> +        self._parse_trailers()\n>  \n>          # Extract the list of modified files\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-status', 'HEAD~'],\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 933BCC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Aug 2024 12:41:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AECB56338D;\n\tWed,  7 Aug 2024 14:41:57 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DC5C96337E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Aug 2024 14:41:56 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C3FF2EC;\n\tWed,  7 Aug 2024 14:41:04 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QbdU49kH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723034464;\n\tbh=SvVw881W5oCcE0vSj5z68BhDbGVQA2GbpN1bIiSLdz4=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=QbdU49kH+y+vqfFUKlaHMWtVaabRYi6fTPBD1aRkKh/67A+2dGn7fDMERJ85R1HLn\n\thWtSW+zwSJ1oebiQ6mqupP8YHSsD4QpSc0Ruadme5PkVbjvwVgPpxzcepaJhk6F1Pc\n\tt8b/V5/078S1PtXyKRgl276M2LxCLwfY5+dFQ0NQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240807121516.13608-4-laurent.pinchart@ideasonboard.com>","References":"<20240807121516.13608-1-laurent.pinchart@ideasonboard.com>\n\t<20240807121516.13608-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH v2 3/3] utils: checkstyle.py: Fix trailer parsing for\n\tcommits with changelogs","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 07 Aug 2024 13:41:53 +0100","Message-ID":"<172303451364.1687952.4264584785377514806@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]