diff options
Diffstat (limited to 'build-gluster-org')
-rw-r--r-- | build-gluster-org/scripts/clang-format.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/build-gluster-org/scripts/clang-format.py b/build-gluster-org/scripts/clang-format.py index ebbd2c4..ba23b04 100644 --- a/build-gluster-org/scripts/clang-format.py +++ b/build-gluster-org/scripts/clang-format.py @@ -1,13 +1,25 @@ #!/usr/bin/env python import subprocess -output = subprocess.check_output(["git-clang-format", "HEAD~", "--diff"]) -if output not in ['no modified files to format\n', - 'clang-format did not modify any files\n']: - print(output) - print("The above patch to be applied to pass clang-format") + +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) -else: - exit(0) +# No changes, pass +print("clang-format did not modify any files") |