diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2021-07-17 09:49:29 +0000 |
---|---|---|
committer | Sam Thursfield <sam@afuera.me.uk> | 2021-07-17 09:49:29 +0000 |
commit | e6c692e74245b58f8034f3d071f9f84374e6ced0 (patch) | |
tree | 90e67b7c58f574ca4d7ffe2e11ddd89621a01459 | |
parent | 0ed35d145fa144af21b6245e56a3f3ed67abd639 (diff) | |
parent | 459076758cbe6f7287bb25b6e85b44d97bfb6b4f (diff) | |
download | tracker-e6c692e74245b58f8034f3d071f9f84374e6ced0.tar.gz |
Merge branch 'wip/carlosg/check-style-fixes' into 'master'
Check style fixes.
See merge request GNOME/tracker!451
-rwxr-xr-x | check-style.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/check-style.py b/check-style.py index df2ae4651..3840e2e01 100755 --- a/check-style.py +++ b/check-style.py @@ -7,8 +7,11 @@ import subprocess import sys import tempfile +# Path relative to this script +uncrustify_cfg = 'utils/uncrustify.cfg' + def run_diff(sha): - proc = subprocess.Popen(["git", "diff", "--function-context", sha, "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + proc = subprocess.Popen(["git", "diff", "-U0", "--function-context", sha, "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) files = proc.stdout.read().strip().decode('utf-8') return files.split('\n') @@ -29,7 +32,7 @@ def find_chunks(diff): len = int(match.group(2)) end = start + len - if file.endswith('.c') or file.endswith('.h') or file.endswith('.vala'): + if len > 0 and (file.endswith('.c') or file.endswith('.h') or file.endswith('.vala')): chunks.append({ 'file': file, 'start': start, 'end': end }) return chunks @@ -46,7 +49,7 @@ def reformat_chunks(chunks, rewrite): tmp.write(bytes(line, 'utf-8')) - if i == end - 1: + if i == end - 2: tmp.write(b'/** *INDENT-OFF* **/\n') tmp.seek(0) @@ -72,7 +75,7 @@ def reformat_chunks(chunks, rewrite): tmp = create_temp_file(chunk['file'], chunk['start'], chunk['end']) # uncrustify chunk - proc = subprocess.Popen(["uncrustify", "-c", "./utils/uncrustify.cfg", "-f", tmp.name], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + proc = subprocess.Popen(["uncrustify", "-c", uncrustify_cfg, "-f", tmp.name], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) reindented = proc.stdout.readlines() tmp.close() |