diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-08-14 10:16:39 +0200 |
---|---|---|
committer | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-08-14 10:16:39 +0200 |
commit | fd70850738ec9b08aeac4d5c3404209781bbdbfe (patch) | |
tree | 9bfe83d336396f9406a1065d2f251a2f71d6ae2b /tools | |
parent | eea551b770fb788c63430c2e459987fedd054220 (diff) |
tools: Reset start line number after group of lines has been found
Without this commit, start line number was never reset. This means that
if you changed lines 10-12 and 230-235 in a file, the
`githelper.get_changed_lines_grouped()` would actually mark lines
10-12 and 10-235 as changed.
This leads to unnecessary and undesired changes made by the clang-format
pre-commit hook.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/clang_format.py | 7 | ||||
-rw-r--r-- | tools/githelper.py | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/tools/clang_format.py b/tools/clang_format.py index d434ad49ca..f868eb0d81 100755 --- a/tools/clang_format.py +++ b/tools/clang_format.py @@ -42,7 +42,12 @@ def run_clang_format_on_lines(rootdir, file_to_format, stylepath=None): ] assert line_arguments - logger.info("Reformatting %s...", file_to_format.filename) + logger.info( + "Reformatting %s [%s]...", + file_to_format.filename, + ", ".join("{}-{}".format(*x) for x in file_to_format.lines), + ) + filename = os.path.join(rootdir, file_to_format.filename) cmd = [ "clang-format", diff --git a/tools/githelper.py b/tools/githelper.py index c526db3d0e..00f18ebd58 100644 --- a/tools/githelper.py +++ b/tools/githelper.py @@ -121,6 +121,7 @@ def get_changed_lines_grouped( grouped_linenumbers.append( (start_linenumber, last_linenumber) ) + start_linenumber = None if start_linenumber is None: start_linenumber = line.number |