diff options
author | Justin Berger <j.david.berger@gmail.com> | 2018-03-23 08:36:03 -0600 |
---|---|---|
committer | Justin Berger <j.david.berger@gmail.com> | 2018-03-23 08:36:18 -0600 |
commit | 5677c23f2ac4b9e099e8e4e4fee72780f303b16c (patch) | |
tree | 39e210a0c49fe41641f73cc2a5b487fde5c6d865 /useful_files | |
parent | fc83b40221ccd935b85bb95a4e9cbe80516b259f (diff) | |
download | libsurvive-5677c23f2ac4b9e099e8e4e4fee72780f303b16c.tar.gz libsurvive-5677c23f2ac4b9e099e8e4e4fee72780f303b16c.tar.bz2 |
Added useful dev files
Diffstat (limited to 'useful_files')
-rwxr-xr-x | useful_files/git-hooks/install.sh | 2 | ||||
-rwxr-xr-x | useful_files/git-hooks/pre-commit | 4 | ||||
-rwxr-xr-x | useful_files/git-hooks/pre-commit.py | 23 |
3 files changed, 29 insertions, 0 deletions
diff --git a/useful_files/git-hooks/install.sh b/useful_files/git-hooks/install.sh new file mode 100755 index 0000000..adefea7 --- /dev/null +++ b/useful_files/git-hooks/install.sh @@ -0,0 +1,2 @@ +ROOT=`git rev-parse --show-toplevel` +cp * $ROOT/.git/hooks diff --git a/useful_files/git-hooks/pre-commit b/useful_files/git-hooks/pre-commit new file mode 100755 index 0000000..a475759 --- /dev/null +++ b/useful_files/git-hooks/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh + +DIRNAME=`dirname "$0"` +python2.7 $DIRNAME/pre-commit.py $@ 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) |