[{"id":14344,"web_url":"https://patchwork.libcamera.org/comment/14344/","msgid":"<X+hkhn/7Yg8Zryml@wyvern>","date":"2020-12-27T10:40:06","subject":"Re: [libcamera-devel] [PATCH 6/8] utils: checkstyle.py: Move diff\n\tparsing to Commit class","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-12-24 14:28:53 +0200, Laurent Pinchart wrote:\n> To avoid duplicating diff parsing in commit checkers, move it to the\n> Commit class.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  utils/checkstyle.py | 13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 07e896d9819f..9c2a1837aa11 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -236,9 +236,10 @@ class Commit:\n>          return self.__title\n>  \n>      def get_diff(self, top_level, filename):\n> -        return subprocess.run(['git', 'diff', '%s~..%s' % (self.commit, self.commit),\n> +        diff = subprocess.run(['git', 'diff', '%s~..%s' % (self.commit, self.commit),\n>                                 '--', '%s/%s' % (top_level, filename)],\n>                                stdout=subprocess.PIPE).stdout.decode('utf-8')\n> +        return parse_diff(diff.splitlines(True))\n>  \n>      def get_file(self, filename):\n>          return subprocess.run(['git', 'show', '%s:%s' % (self.commit, filename)],\n> @@ -256,9 +257,10 @@ class StagedChanges(Commit):\n>          self.__files = [CommitFile(f) for f in ret.splitlines()]\n>  \n>      def get_diff(self, top_level, filename):\n> -        return subprocess.run(['git', 'diff', '--staged', '--',\n> +        diff = subprocess.run(['git', 'diff', '--staged', '--',\n>                                 '%s/%s' % (top_level, filename)],\n>                                stdout=subprocess.PIPE).stdout.decode('utf-8')\n> +        return parse_diff(diff.splitlines(True))\n>  \n>  \n>  class Amendment(StagedChanges):\n> @@ -276,9 +278,10 @@ class Amendment(StagedChanges):\n>          self.__files = [CommitFile(f) for f in ret.splitlines()]\n>  \n>      def get_diff(self, top_level, filename):\n> -        return subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n> +        diff = subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n>                                 '%s/%s' % (top_level, filename)],\n>                                stdout=subprocess.PIPE).stdout.decode('utf-8')\n> +        return parse_diff(diff.splitlines(True))\n>  \n>  \n>  # ------------------------------------------------------------------------------\n> @@ -657,9 +660,7 @@ class StripTrailingSpaceFormatter(Formatter):\n>  \n>  def check_file(top_level, commit, filename):\n>      # Extract the line numbers touched by the commit.\n> -    diff = commit.get_diff(top_level, filename)\n> -    diff = diff.splitlines(True)\n> -    commit_diff = parse_diff(diff)\n> +    commit_diff = commit.get_diff(top_level, filename)\n>  \n>      lines = []\n>      for hunk in commit_diff:\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 A5E95C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 27 Dec 2020 10:40:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3AAF2615B4;\n\tSun, 27 Dec 2020 11:40:12 +0100 (CET)","from mail-lf1-x141.google.com (mail-lf1-x141.google.com\n\t[IPv6:2a00:1450:4864:20::141])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D343615AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Dec 2020 11:40:11 +0100 (CET)","by mail-lf1-x141.google.com with SMTP id x20so17920922lfe.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Dec 2020 02:40:11 -0800 (PST)","from localhost ([185.224.57.161]) by smtp.gmail.com with ESMTPSA id\n\ta7sm4972156lfg.243.2020.12.27.02.40.09\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 27 Dec 2020 02:40:10 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"LQ6bAf3W\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=TYOIqTza1Ci2dpL4ik2OviFxQomRoedy8kyPYnNrCD8=;\n\tb=LQ6bAf3WtncTKOsU42VH1phU9WL6VQIDreFkSWQk7PFmiTUeXkusvBS472c1Vod5Zy\n\t/oFhscBIXJ8Vi6ssj4IvvvrJpeqKqKvoKNY/zmqQBZlkYrGL9mcKiSNuA1Y4F/pif/hD\n\trOOboMRxPlMRVnBhWo20RT71uuAdZVZTCB7gd04nZ5OFZUNmvl8SLQ526jegd672M99F\n\t/PrGqXCRxzlzBV2KbfxlIkn+gFqtR/JX104bCeUQ9GvEhZKVgMBHWUDgaGisg5l79r7R\n\ts6+FFk46z4imrqRD/1aAlh2huSxSdVRZbLEGQaooFH/rjetMvolEi6qFR75zjxerA+Nc\n\tbF2w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=TYOIqTza1Ci2dpL4ik2OviFxQomRoedy8kyPYnNrCD8=;\n\tb=FppJTo1jLE9bvHNGO/K++2sHgz7oQr+Cc03ySxTinGt6b/9GC/9HWAPNrNusLktiSY\n\tlL0+WwuBnE6J6Ou0ehXmsaaeIdDIY+q2xoDUvNOjHhK/JilZjGrIIOV8mXYBiH0MEh8X\n\tHa/ID8cGsdIY2SbOXCQEj/PYlS0JRXGOpK+mYtzmU2DymyCLOIOvVm87bX9A47EOeETg\n\tBxB5q8fcEfbrJyi5ilihmzkRI4nHNxQKRdS7EfDwHRGw+Ul0p8Qalf3nTOZPKHQAKl8l\n\tIMuSURu7sudpqh2LSOxJe2NZr75ZyMQDKDw2RjjzZMFCHPSHmIWjH16NRR+5f+SDQT23\n\tMQKg==","X-Gm-Message-State":"AOAM532sq0IqyWBE+7qhq1fSjM9VHC0tbWhrrDwwm2H0bEGB0ZfDxWPd\n\tPohZwyzu/e912XEHRpuImyfIZJVCd1AIUg==","X-Google-Smtp-Source":"ABdhPJyOg0psyHzrN1LOBYBxyDOGHaWWsFUMlhizSZwLc5I7dLtbBMu2tdEWJ1FWMqlz4jYgXj2pIA==","X-Received":"by 2002:ac2:50ca:: with SMTP id\n\th10mr16653182lfm.383.1609065610770; \n\tSun, 27 Dec 2020 02:40:10 -0800 (PST)","Date":"Sun, 27 Dec 2020 11:40:06 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<X+hkhn/7Yg8Zryml@wyvern>","References":"<20201224122855.22200-1-laurent.pinchart@ideasonboard.com>\n\t<20201224122855.22200-7-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201224122855.22200-7-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 6/8] utils: checkstyle.py: Move diff\n\tparsing to Commit class","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]