{"id":10739,"url":"https://patchwork.libcamera.org/api/patches/10739/?format=json","web_url":"https://patchwork.libcamera.org/patch/10739/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20201224122855.22200-4-laurent.pinchart@ideasonboard.com>","date":"2020-12-24T12:28:50","name":"[libcamera-devel,3/8] utils: checkstyle.py: Move commit handling to a separate section","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"9a506fd6b9bf813ca3de606e6a3a2186aa7a5480","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":{"id":14,"url":"https://patchwork.libcamera.org/api/users/14/?format=json","username":"pinchartl","first_name":"Laurent","last_name":"Pinchart","email":"laurent.pinchart@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/10739/mbox/","series":[{"id":1550,"url":"https://patchwork.libcamera.org/api/series/1550/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1550","date":"2020-12-24T12:28:47","name":"checkstyle.py: Ensure meson.build is updated when adding header","version":1,"mbox":"https://patchwork.libcamera.org/series/1550/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10739/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10739/checks/","tags":{},"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 9D090C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Dec 2020 12:29:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C6F8615AF;\n\tThu, 24 Dec 2020 13:29:13 +0100 (CET)","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 0978F60528\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Dec 2020 13:29:09 +0100 (CET)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9ED28DFC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Dec 2020 13:29:08 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"I4h+YFIf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1608812948;\n\tbh=6yCYwRzf5QvfKinGmTRNPvWOY+FQEs89TQ6h/scAPW8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=I4h+YFIfEuBm4HCfMUVTqy6Qhlbe3L0juQEZ01HhKtaWBx71FrVokPToMtNQGh44D\n\t+eBHQZjtCOkFfoCjDE16+EZs+O4TMk7BXscTAzMWZd67TR2JSoW/6cW6lHdypM/DQe\n\t3hd56yZHOSZSDlCwqT32F+vtVKMHyyAnMmTWF8zw=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 24 Dec 2020 14:28:50 +0200","Message-Id":"<20201224122855.22200-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20201224122855.22200-1-laurent.pinchart@ideasonboard.com>","References":"<20201224122855.22200-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 3/8] utils: checkstyle.py: Move commit\n\thandling to a separate section","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"To prepare for checkers that operate directly on commits, move the\nrelated classes to a separate section. No functional change is included.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/checkstyle.py | 120 +++++++++++++++++++++++---------------------\n 1 file changed, 62 insertions(+), 58 deletions(-)","diff":"diff --git a/utils/checkstyle.py b/utils/checkstyle.py\nindex 76267d5ea764..4ba65e5a4ff1 100755\n--- a/utils/checkstyle.py\n+++ b/utils/checkstyle.py\n@@ -190,6 +190,68 @@ def parse_diff(diff):\n     return hunks\n \n \n+# ------------------------------------------------------------------------------\n+# Commit, Staged Changes & Amendments\n+#\n+\n+class Commit:\n+    def __init__(self, commit):\n+        self.commit = commit\n+\n+    def get_info(self):\n+        # Get the commit title and list of files.\n+        ret = subprocess.run(['git', 'show', '--pretty=oneline', '--name-only',\n+                              self.commit],\n+                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n+        files = ret.splitlines()\n+        # Returning title and files list as a tuple\n+        return files[0], files[1:]\n+\n+    def get_diff(self, top_level, filename):\n+        return 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+\n+    def get_file(self, filename):\n+        return subprocess.run(['git', 'show', '%s:%s' % (self.commit, filename)],\n+                              stdout=subprocess.PIPE).stdout.decode('utf-8')\n+\n+\n+class StagedChanges(Commit):\n+    def __init__(self):\n+        Commit.__init__(self, '')\n+\n+    def get_info(self):\n+        ret = subprocess.run(['git', 'diff', '--staged', '--name-only'],\n+                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n+        return \"Staged changes\", ret.splitlines()\n+\n+    def get_diff(self, top_level, filename):\n+        return subprocess.run(['git', 'diff', '--staged', '--',\n+                               '%s/%s' % (top_level, filename)],\n+                              stdout=subprocess.PIPE).stdout.decode('utf-8')\n+\n+\n+class Amendment(StagedChanges):\n+    def __init__(self):\n+        StagedChanges.__init__(self)\n+\n+    def get_info(self):\n+        # Create a title using HEAD commit\n+        ret = subprocess.run(['git', 'show', '--pretty=oneline', '--no-patch'],\n+                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n+        title = 'Amendment of ' + ret.strip()\n+        # Extract the list of modified files\n+        ret = subprocess.run(['git', 'diff', '--staged', '--name-only', 'HEAD~'],\n+                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n+        return title, ret.splitlines()\n+\n+    def get_diff(self, top_level, filename):\n+        return subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n+                               '%s/%s' % (top_level, filename)],\n+                              stdout=subprocess.PIPE).stdout.decode('utf-8')\n+\n+\n # ------------------------------------------------------------------------------\n # Helpers\n #\n@@ -564,64 +626,6 @@ class StripTrailingSpaceFormatter(Formatter):\n # Style checking\n #\n \n-class Commit:\n-    def __init__(self, commit):\n-        self.commit = commit\n-\n-    def get_info(self):\n-        # Get the commit title and list of files.\n-        ret = subprocess.run(['git', 'show', '--pretty=oneline', '--name-only',\n-                              self.commit],\n-                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n-        files = ret.splitlines()\n-        # Returning title and files list as a tuple\n-        return files[0], files[1:]\n-\n-    def get_diff(self, top_level, filename):\n-        return 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-\n-    def get_file(self, filename):\n-        return subprocess.run(['git', 'show', '%s:%s' % (self.commit, filename)],\n-                              stdout=subprocess.PIPE).stdout.decode('utf-8')\n-\n-\n-class StagedChanges(Commit):\n-    def __init__(self):\n-        Commit.__init__(self, '')\n-\n-    def get_info(self):\n-        ret = subprocess.run(['git', 'diff', '--staged', '--name-only'],\n-                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n-        return \"Staged changes\", ret.splitlines()\n-\n-    def get_diff(self, top_level, filename):\n-        return subprocess.run(['git', 'diff', '--staged', '--',\n-                               '%s/%s' % (top_level, filename)],\n-                              stdout=subprocess.PIPE).stdout.decode('utf-8')\n-\n-\n-class Amendment(StagedChanges):\n-    def __init__(self):\n-        StagedChanges.__init__(self)\n-\n-    def get_info(self):\n-        # Create a title using HEAD commit\n-        ret = subprocess.run(['git', 'show', '--pretty=oneline', '--no-patch'],\n-                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n-        title = 'Amendment of ' + ret.strip()\n-        # Extract the list of modified files\n-        ret = subprocess.run(['git', 'diff', '--staged', '--name-only', 'HEAD~'],\n-                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n-        return title, ret.splitlines()\n-\n-    def get_diff(self, top_level, filename):\n-        return subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n-                               '%s/%s' % (top_level, filename)],\n-                              stdout=subprocess.PIPE).stdout.decode('utf-8')\n-\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","prefixes":["libcamera-devel","3/8"]}