mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #3781
3781: Only use correct clang-format version r=heinrich5991 a=def- <!-- What is the motivation for the changes of this pull request --> ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
4cb65aa2d8
|
@ -26,11 +26,27 @@ def filter_cpp(filenames):
|
|||
return [filename for filename in filenames
|
||||
if any(filename.endswith(ext) for ext in ".c .cpp .h".split())]
|
||||
|
||||
def find_clang_format(version):
|
||||
for binary in (
|
||||
"clang-format",
|
||||
"clang-format-{}".format(version),
|
||||
"/opt/clang-format-static/clang-format-{}".format(version)):
|
||||
try:
|
||||
out = subprocess.check_output([binary, "--version"])
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
if "clang-format version {}.".format(version) in out.decode("utf-8"):
|
||||
return binary
|
||||
print("Found no clang-format {}".format(version))
|
||||
sys.exit(-1)
|
||||
|
||||
clang_format_bin = find_clang_format(10)
|
||||
|
||||
def reformat(filenames):
|
||||
subprocess.check_call(["clang-format", "-i"] + filenames)
|
||||
subprocess.check_call([clang_format_bin, "-i"] + filenames)
|
||||
|
||||
def warn(filenames):
|
||||
return subprocess.call(["clang-format", "-Werror", "--dry-run"] + filenames)
|
||||
return subprocess.call([clang_format_bin, "-Werror", "--dry-run"] + filenames)
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description="Check and fix style of changed files")
|
||||
|
|
Loading…
Reference in a new issue