<filename>useful_files/git-hooks/pre-commit.py<gh_stars>0
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)

<filename>useful_files/git-hooks/pre-commit.py<gh_stars>0
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)
