mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 13:38:18 +00:00
check for newline at the end of source files
This commit is contained in:
parent
47d77fad07
commit
e46f16ed91
|
@ -52,10 +52,29 @@ def find_clang_format(version):
|
|||
clang_format_bin = find_clang_format(10)
|
||||
|
||||
def reformat(filenames):
|
||||
for filename in filenames:
|
||||
with open(filename, 'r+b') as f:
|
||||
try:
|
||||
f.seek(-1, os.SEEK_END)
|
||||
if f.read(1) != b'\n':
|
||||
f.write(b'\n')
|
||||
except OSError:
|
||||
f.seek(0)
|
||||
subprocess.check_call([clang_format_bin, "-i"] + filenames)
|
||||
|
||||
def warn(filenames):
|
||||
return subprocess.call([clang_format_bin, "-Werror", "--dry-run"] + filenames)
|
||||
clang = subprocess.call([clang_format_bin, "-Werror", "--dry-run"] + filenames)
|
||||
newline = 0
|
||||
for filename in filenames:
|
||||
with open(filename, 'rb') as f:
|
||||
try:
|
||||
f.seek(-1, os.SEEK_END)
|
||||
if f.read(1) != b'\n':
|
||||
print(filename + ": error: missing newline at EOF", file=sys.stderr)
|
||||
newline = 1
|
||||
except OSError:
|
||||
f.seek(0)
|
||||
return clang or newline
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description="Check and fix style of changed files")
|
||||
|
|
Loading…
Reference in a new issue