Patch Detail
Show a patch.
GET /api/1.1/patches/55/?format=api
{ "id": 55, "url": "https://patchwork.libcamera.org/api/1.1/patches/55/?format=api", "web_url": "https://patchwork.libcamera.org/patch/55/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20181218204609.22902-2-laurent.pinchart@ideasonboard.com>", "date": "2018-12-18T20:46:09", "name": "[libcamera-devel,2/2] utils: checkstyle.py: Strip trailing white spaces", "commit_ref": "3c8886d6981e1238657cc6ee9dcf267f090fca41", "pull_url": null, "state": "accepted", "archived": false, "hash": "964ae8b3db8bcfcb3436d615ff9dcc261685ac7f", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/55/mbox/", "series": [ { "id": 29, "url": "https://patchwork.libcamera.org/api/1.1/series/29/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=29", "date": "2018-12-18T20:46:09", "name": "[libcamera-devel,1/2] utils: checkstyle.py: Highlight trailing white space at end of line", "version": 1, "mbox": "https://patchwork.libcamera.org/series/29/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/55/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/55/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 972A260B0C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Dec 2018 21:45:21 +0100 (CET)", "from avalon.bb.dnainternet.fi\n\t(dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 22FD9549\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Dec 2018 21:45:20 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1545165920;\n\tbh=k67WhWz0yJkn+wjdZyxfq8bu5iTbKSxsdxKjI97LGgA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=fjPak4XPCXtiHHsAANPm0N2ky//4prFSL496wHmNKuEaUZirrcnVw8HG3a2tjHMA/\n\t+pY1O2DgFaUzf8g2UbU9wGr95qOSZsg/6v+yrBhef3SUyYXuitDptW2hI5lhiGNpaR\n\tJIJbskOUnAMXgXN9lIEGK1dm6Bla8oiLREqBqBE0=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 18 Dec 2018 22:46:09 +0200", "Message-Id": "<20181218204609.22902-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20181218204609.22902-1-laurent.pinchart@ideasonboard.com>", "References": "<20181218204609.22902-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/2] utils: checkstyle.py: Strip trailing\n\twhite spaces", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "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>", "X-List-Received-Date": "Tue, 18 Dec 2018 20:45:21 -0000" }, "content": "As astyle doesn't strip trailing white spaces, strip them manually.\nOrganize the code to allow for new additional formatting steps if\nneeded.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/checkstyle.py | 49 +++++++++++++++++++++++++++++++++++++++------\n 1 file changed, 43 insertions(+), 6 deletions(-)", "diff": "diff --git a/utils/checkstyle.py b/utils/checkstyle.py\nindex dadb55dfb8c1..32974815048a 100755\n--- a/utils/checkstyle.py\n+++ b/utils/checkstyle.py\n@@ -38,6 +38,10 @@ source_extensions = (\n '.h'\n )\n \n+# ------------------------------------------------------------------------------\n+# Colour terminal handling\n+#\n+\n class Colours:\n Default = 0\n Black = 0\n@@ -79,6 +83,10 @@ class Colours:\n return ''\n \n \n+# ------------------------------------------------------------------------------\n+# Diff parsing, handling and printing\n+#\n+\n class DiffHunkSide(object):\n \"\"\"A side of a diff hunk, recording line numbers\"\"\"\n def __init__(self, start):\n@@ -179,6 +187,33 @@ def parse_diff(diff):\n return hunks\n \n \n+# ------------------------------------------------------------------------------\n+# Code reformatting\n+#\n+\n+def formatter_astyle(data):\n+ ret = subprocess.run(['astyle', *astyle_options],\n+ input=data.encode('utf-8'), stdout=subprocess.PIPE)\n+ return ret.stdout.decode('utf-8')\n+\n+\n+def formatter_strip_trailing_space(data):\n+ lines = data.split('\\n')\n+ for i in range(len(lines)):\n+ lines[i] = lines[i].rstrip() + '\\n'\n+ return ''.join(lines)\n+\n+\n+formatters = [\n+ formatter_astyle,\n+ formatter_strip_trailing_space,\n+]\n+\n+\n+# ------------------------------------------------------------------------------\n+# Style checking\n+#\n+\n def check_file(top_level, commit, filename):\n # Extract the line numbers touched by the commit.\n diff = subprocess.run(['git', 'diff', '%s~..%s' % (commit, commit), '--',\n@@ -195,16 +230,18 @@ def check_file(top_level, commit, filename):\n if len(lines) == 0:\n return 0\n \n- # Format the file after the commit with astyle and compute the diff between\n- # the two files.\n+ # Format the file after the commit with all formatters and compute the diff\n+ # between the unformatted and formatted contents.\n after = subprocess.run(['git', 'show', '%s:%s' % (commit, filename)],\n stdout=subprocess.PIPE).stdout\n- formatted = subprocess.run(['astyle', *astyle_options],\n- input=after, stdout=subprocess.PIPE).stdout\n+ after = after.decode('utf-8')\n \n- after = after.decode('utf-8').splitlines(True)\n- formatted = formatted.decode('utf-8').splitlines(True)\n+ formatted = after\n+ for formatter in formatters:\n+ formatted = formatter(formatted)\n \n+ after = after.splitlines(True)\n+ formatted = formatted.splitlines(True)\n diff = difflib.unified_diff(after, formatted)\n \n # Split the diff in hunks, recording line number ranges for each hunk.\n", "prefixes": [ "libcamera-devel", "2/2" ] }