summaryrefslogtreecommitdiff
path: root/utils/checkstyle.py
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2020-01-07 15:23:04 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2020-01-07 16:37:28 +0000
commit300654217eb5bfd5c6aaacc3f90ccec618239f75 (patch)
tree2d53e8708d3b5448bf471e96827e1954f9cfd64d /utils/checkstyle.py
parent32dd1a3b2f813fa39121d3c9781379d1d3208611 (diff)
utils: checkstyle.py: Support single line hunks
The checkstyle script expects hunks to be declared with a start line and line count, however the unified diff format [0] declares that a single line hunk will only have the start line: > If a hunk contains just one line, only its start line number appears. > Otherwise its line numbers look like ‘start,count’. An empty hunk is > considered to start at the line that follows the hunk. [0] https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html#Detailed-Unified Attempting to parse a single line hunk results in the following error: File "./utils/checkstyle.py", line 110, in __init__ raise RuntimeError("Malformed diff hunk header '%s'" % line) RuntimeError: Malformed diff hunk header '@@ -1 +1,2 @@ The DiffHunk class only makes use of the start line, and does not utilise the line count, thus update the regex to make the unused groups optional. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'utils/checkstyle.py')
-rwxr-xr-xutils/checkstyle.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index 41cd3371..93f02911 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -102,7 +102,7 @@ class DiffHunkSide(object):
class DiffHunk(object):
- diff_header_regex = re.compile(r'@@ -([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@')
+ diff_header_regex = re.compile(r'@@ -([0-9]+),?([0-9]+)? \+([0-9]+),?([0-9]+)? @@')
def __init__(self, line):
match = DiffHunk.diff_header_regex.match(line)