[{"id":14345,"web_url":"https://patchwork.libcamera.org/comment/14345/","msgid":"<X+hk4qjmJabrkFD4@wyvern>","date":"2020-12-27T10:41:38","subject":"Re: [libcamera-devel] [PATCH 7/8] utils: checkstyle.py: Add commit\n\tcheckers","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:54 +0200, Laurent Pinchart wrote:\n> Add a new category of checkers that operate on a whole commit.\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 | 42 +++++++++++++++++++++++++++++++++++-------\n>  1 file changed, 35 insertions(+), 7 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 9c2a1837aa11..c0a6b7ab06cd 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -296,6 +296,30 @@ class ClassRegistry(type):\n>          return newclass\n>  \n>  \n> +# ------------------------------------------------------------------------------\n> +# Commit Checkers\n> +#\n> +\n> +class CommitChecker(metaclass=ClassRegistry):\n> +    subclasses = []\n> +\n> +    def __init__(self):\n> +        pass\n> +\n> +    #\n> +    # Class methods\n> +    #\n> +    @classmethod\n> +    def checkers(cls):\n> +        for checker in cls.subclasses:\n> +            yield checker\n> +\n> +\n> +class CommitIssue(object):\n> +    def __init__(self, msg):\n> +        self.msg = msg\n> +\n> +\n>  # ------------------------------------------------------------------------------\n>  # Style Checkers\n>  #\n> @@ -721,25 +745,29 @@ def check_style(top_level, commit):\n>      print(commit.title)\n>      print(separator)\n>  \n> +    issues = 0\n> +\n> +    # Apply the commit checkers first.\n> +    for checker in CommitChecker.checkers():\n> +        for issue in checker.check(commit, top_level):\n> +            print('%s%s%s' % (Colours.fg(Colours.Yellow), issue.msg, Colours.reset()))\n> +            issues += 1\n> +\n>      # Filter out files we have no checker for.\n>      patterns = set()\n>      patterns.update(StyleChecker.all_patterns())\n>      patterns.update(Formatter.all_patterns())\n>      files = [f for f in commit.files() if len([p for p in patterns if fnmatch.fnmatch(os.path.basename(f), p)])]\n> -    if len(files) == 0:\n> -        print(\"Commit doesn't touch source files, skipping\")\n> -        return 0\n>  \n> -    issues = 0\n>      for f in files:\n>          issues += check_file(top_level, commit, f)\n>  \n>      if issues == 0:\n> -        print(\"No style issue detected\")\n> +        print(\"No issue detected\")\n>      else:\n>          print('---')\n> -        print(\"%u potential style %s detected, please review\" % \\\n> -                (issues, 'issue' if issues == 1 else 'issues'))\n> +        print(\"%u potential %s detected, please review\" %\n> +              (issues, 'issue' if issues == 1 else 'issues'))\n>  \n>      return issues\n>  \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 E17BEC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 27 Dec 2020 10:41:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AE31B615B0;\n\tSun, 27 Dec 2020 11:41:42 +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 87FCD615AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Dec 2020 11:41:41 +0100 (CET)","by mail-lf1-x141.google.com with SMTP id o19so18058863lfo.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Dec 2020 02:41:41 -0800 (PST)","from localhost ([185.224.57.161]) by smtp.gmail.com with ESMTPSA id\n\tv7sm5839074ljk.60.2020.12.27.02.41.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 27 Dec 2020 02:41:40 -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=\"nF80oRT3\"; 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=A4gYs3aKQyYwZKCE2Mv9APCAY1CGf0Ob11TrOwAjz+Q=;\n\tb=nF80oRT3HzkhCR3YcnY7dLe27p9KtJiiPdQQQyOScIbOXjcDJ+gkrKxSthiwu8qtX+\n\tCdXG7xCKcWfjiTDwBx33A4mPt5Cp6WiplSdTRb51j8WsUjsR1eGKXWweInxedxk2TKmk\n\t8eY6aAD/U32/lGaW2tW185I8JS7/7oHMWSkbtK23NLq4qCyhIXHA1lm4NY8W/nRcevt8\n\tlcXqmySS7UAHsGmaJos5K6YRA0d516paw+MFiV10ldtSh9V3CcF2vL1zVrzVKMvfp31A\n\tVJmuv3xhcnGdMgyQkVV8bO40skU1JF4ThV9fW82lIdnIF1195qHPSVbtt9nIpxadqDAG\n\tNOpA==","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=A4gYs3aKQyYwZKCE2Mv9APCAY1CGf0Ob11TrOwAjz+Q=;\n\tb=hBqTDbmprp+HK5pxioj0cp93J0k8coaU+RdDge6bMhtcbOeN4ZAWzJMfZKSoNCM3b1\n\t16wPXFg5J6kIYDirhWVM4bw1+WZDyblk5n/ox2yTqOrJayodR+MaX0c/MeftHwqFy9yd\n\tw3qlEQLeFOKjXupfab6Qy32tzHswIGb5oJzh8pF6D4E7yP0Tg7ZsNvcPiUKYNHl2zJ03\n\tsmprKEK75nhOARw6BOHBWpo7fFwY0x9hpt/XVagnKz9N+mn0grporDPYA5l5VpEoPaFF\n\tcIFZgQONUPHQgHfXPhbj5pSrHulD2YuNQmubqAD2ZqA04mqICUeWCnbgY3vcHU0+sBYz\n\t+Zhw==","X-Gm-Message-State":"AOAM531t8shkQ6+Y5SwDgtRmlI78EV3YV32OERz5DFuEJpL+Vpx3V1+Q\n\t++r7llorSX3SMNmK6GXjtxO851eUJCN8iw==","X-Google-Smtp-Source":"ABdhPJxhslWnYWLMSaK7LWOXgkl/6bVBPBdSf3sNIeWTKB8NSVyS/QO4cwQN+kDDHBScGAGgsaEZuQ==","X-Received":"by 2002:a19:c815:: with SMTP id\n\ty21mr16640381lff.324.1609065701037; \n\tSun, 27 Dec 2020 02:41:41 -0800 (PST)","Date":"Sun, 27 Dec 2020 11:41:38 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<X+hk4qjmJabrkFD4@wyvern>","References":"<20201224122855.22200-1-laurent.pinchart@ideasonboard.com>\n\t<20201224122855.22200-8-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201224122855.22200-8-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 7/8] utils: checkstyle.py: Add commit\n\tcheckers","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>"}}]