Skip to content

Commit

Permalink
Added useful dev files
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavidberger committed Mar 23, 2018
1 parent fc83b40 commit 5677c23
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .clang-format
@@ -0,0 +1,4 @@
IndentWidth: '4'
TabWidth: '4'
UseTab: Always
ColumnLimit: 120
2 changes: 2 additions & 0 deletions useful_files/git-hooks/install.sh
@@ -0,0 +1,2 @@
ROOT=`git rev-parse --show-toplevel`
cp * $ROOT/.git/hooks
4 changes: 4 additions & 0 deletions useful_files/git-hooks/pre-commit
@@ -0,0 +1,4 @@
#!/bin/sh

DIRNAME=`dirname "$0"`
python2.7 $DIRNAME/pre-commit.py $@
23 changes: 23 additions & 0 deletions 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)

0 comments on commit 5677c23

Please sign in to comment.