aboutsummaryrefslogtreecommitdiff
path: root/useful_files/git-hooks/pre-commit.py
diff options
context:
space:
mode:
authorJustin Berger <j.david.berger@gmail.com>2018-04-02 10:10:33 -0600
committerJustin Berger <j.david.berger@gmail.com>2018-04-02 10:10:33 -0600
commit75460f240c9d003e4ca2e6dda9b2146a74df7ffa (patch)
tree957b26f0539df176b61ad2ec72fbb0658b147919 /useful_files/git-hooks/pre-commit.py
parent2b63278497130d01b1fbc7e6a94b6ad8e32ab4dd (diff)
parent1724abef15a4090640bd82ba408681438316de7e (diff)
downloadlibsurvive-75460f240c9d003e4ca2e6dda9b2146a74df7ffa.tar.gz
libsurvive-75460f240c9d003e4ca2e6dda9b2146a74df7ffa.tar.bz2
Merge remote-tracking branch 'origin/master' into imu
Diffstat (limited to 'useful_files/git-hooks/pre-commit.py')
-rwxr-xr-xuseful_files/git-hooks/pre-commit.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/useful_files/git-hooks/pre-commit.py b/useful_files/git-hooks/pre-commit.py
new file mode 100755
index 0000000..565c363
--- /dev/null
+++ b/useful_files/git-hooks/pre-commit.py
@@ -0,0 +1,23 @@
+import subprocess
+
+try:
+ run_args = ["git", "clang-format"]
+
+ print("Running clang-format...")
+ output = subprocess.check_output(run_args)
+ print output
+ changed_list = output.split('\n')
+ if changed_list[0] == 'changed files:':
+ changed_list.pop(0)
+ for changed in changed_list:
+ if len(changed.strip()) > 0:
+ add_output = subprocess.check_output(['git', 'add', changed.strip()])
+ if len(add_output) > 0:
+ print(add_output)
+ exit(0)
+except subprocess.CalledProcessError as e:
+ print(e.output)
+ exit(1)
+except Exception as e:
+ print "Clang format not installed; please install: ", e
+ exit(0)