blob: 09ce57816b4aa953fea6bd9574223626edb23699 [file] [log] [blame]
#!/bin/sh
#
# A hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook exits with
# non-zero status if the files being committed do not conform to
# to the Mesos style.
#
# To enable this hook, do this from the root of the repo:
#
# $ ln -s ../../support/hooks/pre-commit .git/hooks/pre-commit
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Redirect output to stderr.
exec 1>&2
# If there are whitespace errors, print the offending file names and fail.
git diff-index --check --cached $against -- || exit 1
# Check Mesos style.
exec git diff --cached --name-only --diff-filter=AM | xargs ./support/mesos-style.py
# Check that the commits are properly split between mesos, libprocess and stout.
exec git diff --cached --name-only --diff-filter=AMD | xargs ./support/mesos_split.py