blob: ba23b04f824776454a13c6c5ba37745e4dc2c813 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/usr/bin/env python
import subprocess
changed_files = subprocess.check_output(
["git", "diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD"]
).split("\n")
list_of_files = []
for file in changed_files:
if file.startswith("contrib/"):
continue
if file.endswith(".c") or file.endswith(".h"):
subprocess.call(['clang-format', '-i', file])
# Look for any changes applied by clang-format
changed = subprocess.check_output(['git', 'diff'])
if changed:
print(changed)
print("The above patch needs to be applied to pass clang-format")
exit(1)
# No changes, pass
print("clang-format did not modify any files")
|