You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2014/05/16 01:12:55 UTC

git commit: Added a pre-commit hook to check style.

Repository: mesos
Updated Branches:
  refs/heads/master 4f97402d7 -> 841cdbdc0


Added a pre-commit hook to check style.

Review: https://reviews.apache.org/r/21439


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/841cdbdc
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/841cdbdc
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/841cdbdc

Branch: refs/heads/master
Commit: 841cdbdc0ce6211d983fc9dfb7e08ca253a97099
Parents: 4f97402
Author: Vinod Kone <vi...@twitter.com>
Authored: Wed May 14 10:34:15 2014 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Thu May 15 16:12:43 2014 -0700

----------------------------------------------------------------------
 docs/mesos-developers-guide.md |  2 +-
 support/hooks/pre-commit       | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/841cdbdc/docs/mesos-developers-guide.md
----------------------------------------------------------------------
diff --git a/docs/mesos-developers-guide.md b/docs/mesos-developers-guide.md
index d195bde..036a6fd 100644
--- a/docs/mesos-developers-guide.md
+++ b/docs/mesos-developers-guide.md
@@ -32,7 +32,7 @@ layout: documentation
 1. Create one or more test cases to exercise the bug or the feature (the Mesos team uses [test-driven development](http://en.wikipedia.org/wiki/Test-driven_development)), before you start coding, make sure these test cases all fail.
 
 1. Make your changes to the code (using whatever IDE/editor you choose) to actually fix the bug or implement the feature.
-    2. Before beginning, please read the [Mesos C++ Style Guide](mesos-c++-style-guide.md)
+    2. Before beginning, please read the [Mesos C++ Style Guide](mesos-c++-style-guide.md). It is recommended to use the git pre-commit hook (`support/hooks/pre-commit`) to automatically check for style errors. See the hook script for instructions to enable it.
     2. Most of your changes will probably be to files inside of `BASE_MESOS_DIR`
     2. To build, we recommend that you don't build inside of the src directory. We recommend you do the following:
         3. From inside of the root Mesos directory: `mkdir build && cd build`

http://git-wip-us.apache.org/repos/asf/mesos/blob/841cdbdc/support/hooks/pre-commit
----------------------------------------------------------------------
diff --git a/support/hooks/pre-commit b/support/hooks/pre-commit
new file mode 100755
index 0000000..a371967
--- /dev/null
+++ b/support/hooks/pre-commit
@@ -0,0 +1,27 @@
+#!/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 -z $against | xargs ./support/mesos-style.py