Fetching contributors…
Cannot retrieve contributors at this time
executable file 42 lines (36 sloc) 1.57 KB
# 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
# 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
# Initial commit: diff against an empty tree object
# 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.
ADDED_OR_MODIFIED=$(git diff --cached --name-only --diff-filter=AM)
if [ -n "$ADDED_OR_MODIFIED" ]; then
# NOTE: We choose to implement this as a conditional rather than a call to
# `xargs` on purpose. Some implementations of `xargs` will call your script
# even if the arguments you pass in are empty. In our case, this would
# cause us to erroneously lint every file in the repository. Additionally,
# many implementations do not support the `-r` flag, (which instructs
# `xargs` to not run the script if the arguments are empty), so we also
# cannot use that.
./support/ $ADDED_OR_MODIFIED || exit 1
# Check that the commits are properly split between mesos, libprocess and stout.
# TODO(ArmandGrillet): Remove the if to really switch to Python 3.
git diff --cached --name-only --diff-filter=AMD | xargs ./support/ || exit 1