[{"id":27538,"web_url":"https://patchwork.libcamera.org/comment/27538/","msgid":"<431c10ae-9020-9081-ed29-ab20e1a040b0@ideasonboard.com>","date":"2023-07-11T14:23:31","subject":"Re: [libcamera-devel] [PATCH 4/4] utils: checkstyle.py: Check\n\ttrailers for Amendment commits","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Kieran,\n\n\nOn 7/11/23 7:09 PM, Kieran Bingham via libcamera-devel wrote:\n> The commit trailers are checked as part of processing the commit message\n> with the newly introduced TrailersChecker.\n>\n> This relies on the trailers property being correctly exposed by the\n> Commit object, and is implemented for the base Commit but not processed\n> for Amendment commits.\n>\n> Refactor the trailer property handling to a helper function in the base\n> Commit class and make use of it with a newly added call to obtain the\n> existing Trailers from the most recent commit when using Amendment.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>   utils/checkstyle.py | 26 ++++++++++++++++++--------\n>   1 file changed, 18 insertions(+), 8 deletions(-)\n>\n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 5663af811961..214509bc74d4 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -208,6 +208,17 @@ class Commit:\n>           self.commit = commit\n>           self._parse()\n>   \n> +    def _parse_trailers(self, lines):\n> +        self._trailers = []\n> +        for index in range(1, len(lines)):\n> +            line = lines[index]\n> +            if not line:\n> +                break\n> +\n> +            self._trailers.append(line)\n> +\n> +        return index\n> +\n>       def _parse(self):\n>           # Get the commit title and list of files.\n>           ret = subprocess.run(['git', 'show', '--format=%s%n%(trailers:only,unfold)', '--name-status',\n> @@ -217,14 +228,7 @@ class Commit:\n>   \n>           self._title = lines[0]\n>   \n> -        self._trailers = []\n> -        for index in range(1, len(lines)):\n> -            line = lines[index]\n> -            if not line:\n> -                break\n> -\n> -            self._trailers.append(line)\n> -\n> +        index = self._parse_trailers(lines)\n>           self._files = [CommitFile(f) for f in lines[index:] if f]\n>   \n>       def files(self, filter='AMR'):\n> @@ -283,6 +287,12 @@ class Amendment(Commit):\n>                                stdout=subprocess.PIPE).stdout.decode('utf-8')\n>           self._files = [CommitFile(f) for f in ret.splitlines()]\n>   \n> +        # Parse trailers from the existing commit only.\n> +        ret = subprocess.run(['git', 'show', '--format=%n%(trailers:only,unfold)',\n> +                             '--no-patch'],\n> +                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n> +        self._parse_trailers(ret.splitlines())\n> +\n>       def get_diff(self, top_level, filename):\n>           diff = subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n>                                  '%s/%s' % (top_level, filename)],","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 053B9BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 11 Jul 2023 14:23:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7A644628C0;\n\tTue, 11 Jul 2023 16:23:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B82C360570\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 11 Jul 2023 16:23:35 +0200 (CEST)","from [192.168.1.108] (unknown [103.251.226.37])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 64BC849E;\n\tTue, 11 Jul 2023 16:22:46 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689085417;\n\tbh=sr7AnzRbB2EjRnWQcsO79Zf7l0Y6jeTQtpKgm+QuZDM=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=qX+KJYKQvdkTqv+88N5NjmEJzk5bxBmyHXxUfunS+x/p9INMLSZhojKiQURkUeCSp\n\te/xZFuq3zr8L1sIUdy0RDo6gS16ZGoqNFcJRsvHjizR/fqY3x67+Beahhf0yCgTW8n\n\ttL3CCQSkdy+B8bCyZOF4vmreSUmxN04XPsPfDy4CZa/j4La4MoTKMj09FnmviI5pDb\n\trHdl03xcA/S95oEBDbh4qWKMtILXRoOfVKx+D9cgFtw0bj9WLRxQH56bbX80IVnWs9\n\teZJIFMYaeGuR6JoXlxcu+wMHRlEi1fLggOWIATRaMtkMTEdQDBtw1Yf9Jo714gdmN3\n\tdSOZ0pKlCEYAg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1689085366;\n\tbh=sr7AnzRbB2EjRnWQcsO79Zf7l0Y6jeTQtpKgm+QuZDM=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=o7kon6dibQ0mVD3aSKpLdOr07KjQt8mPX+faI79poqP35nl/8R8A+mUpYh7Q0k51g\n\tSp7PtFnFqM6NUaF8GV9W3B3Unk+BGxqdmMTeTr1cv2Uk3NzgEHfKTduW3yNPIgpylv\n\tTpMtqi0iaXwiYqmSPwsVN1/Hji5RN5sMYolK2bB0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"o7kon6di\"; dkim-atps=neutral","Message-ID":"<431c10ae-9020-9081-ed29-ab20e1a040b0@ideasonboard.com>","Date":"Tue, 11 Jul 2023 19:53:31 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101\n\tThunderbird/102.7.1","Content-Language":"en-US","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","References":"<20230711133915.650485-1-kieran.bingham@ideasonboard.com>\n\t<20230711133915.650485-5-kieran.bingham@ideasonboard.com>","In-Reply-To":"<20230711133915.650485-5-kieran.bingham@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 4/4] utils: checkstyle.py: Check\n\ttrailers for Amendment commits","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>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]