You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2015/12/10 00:12:08 UTC

[1/2] mesos git commit: Windows: Added `bootstrap.bat`.

Repository: mesos
Updated Branches:
  refs/heads/master 6093addd8 -> 46d559fe5


Windows: Added `bootstrap.bat`.

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


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

Branch: refs/heads/master
Commit: 56a814862692360fd0cb8107730750ac592b2f99
Parents: 6093add
Author: Alex Clemmer <cl...@gmail.com>
Authored: Wed Dec 9 15:00:31 2015 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Wed Dec 9 15:03:40 2015 -0800

----------------------------------------------------------------------
 bootstrap.bat | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/56a81486/bootstrap.bat
----------------------------------------------------------------------
diff --git a/bootstrap.bat b/bootstrap.bat
new file mode 100644
index 0000000..9ca1421
--- /dev/null
+++ b/bootstrap.bat
@@ -0,0 +1,68 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+::
+::     http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing, software
+:: distributed under the License is distributed on an "AS IS" BASIS,
+:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+:: See the License for the specific language governing permissions and
+:: limitations under the License.
+
+@echo off
+
+:: Make sure that we are in the right directory. We do this by checking that
+:: the `support` folder exists in the current directory and is not a symlink.
+:: This code is awkwardly split across two conditionals because batch scripts
+:: do not support logical operators like `&&`.
+::
+:: NOTE: The Linux equivalent (`bootstrap`, a script written in Bash) instead
+:: checks that `configure.ac` exists and is not a symlink; since we expect to
+:: deprecate the autotools build system, we choose not to verify the current
+:: directory by checking that `configure.ac` script exists, since we expect it
+:: to go away soon. Instead, we depend on finding the `support/` folder, which
+:: we expect to be permanent (i.e., we expect to copy files from it anyway).
+if not exist support (
+  goto not_in_root
+)
+
+fsutil reparsepoint query "support" | find "Symbolic Link" >nul && (
+  goto not_in_root
+)
+
+:: Install mesos default hooks and gitignore template.
+if not exist .git\hooks\pre-commit (
+  mklink .git\hooks\pre-commit ..\..\support\hooks\pre-commit
+)
+
+if not exist .git\hooks\post-rewrite (
+  mklink .git\hooks\post-rewrite ..\..\support\hooks\post-rewrite
+)
+
+if not exist .gitignore (
+  mklink .gitignore .gitignore-template
+)
+
+if not exist .reviewboardrc (
+  mklink .reviewboardrc support\reviewboardrc
+)
+
+if not exist .clang-format (
+  mklink .clang-format support\clang-format
+)
+
+goto:eof
+
+
+:: If we are not in the root directory, print error and exit.
+:not_in_root
+echo. 1>&2
+echo You must run bootstrap from the root of the distribution. 1>&2
+echo. 1>&2
+
+exit /b 1


[2/2] mesos git commit: Changed commit hook linting to ignore empty diffs.

Posted by jo...@apache.org.
Changed commit hook linting to ignore empty diffs.

On Windows, if you attempt to commit an empty changeset, the commit
hooks will attempt to lint the entire repository. This is because we
pass blank arguments to the call to `xargs` that kicks off the C++
linter (e.g., in `support/pre-commit`). In the git bash, the default
behavior of blank arguments is *not* to ignore them, as it is on certain
other platforms. Note that the `-r` flag is provided to avoid this
behavior, but it is only available on some platforms, and hence is
inadmissable here.

Hence, our solution is to check if the results of `git diff` are empty,
and only call `mesos-style.py` if not.

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


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

Branch: refs/heads/master
Commit: 46d559fe5047c048d4f25574dcd13c5ba35c3279
Parents: 56a8148
Author: Alex Clemmer <cl...@gmail.com>
Authored: Wed Dec 9 15:02:29 2015 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Wed Dec 9 15:06:43 2015 -0800

----------------------------------------------------------------------
 support/hooks/post-rewrite | 12 +++++++++++-
 support/hooks/pre-commit   | 12 +++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/46d559fe/support/hooks/post-rewrite
----------------------------------------------------------------------
diff --git a/support/hooks/post-rewrite b/support/hooks/post-rewrite
index 7df1e0f..af907de 100755
--- a/support/hooks/post-rewrite
+++ b/support/hooks/post-rewrite
@@ -21,7 +21,17 @@ git diff-index --check @~ -- || exit 1
 ## In git, '@' represent current head, '@~' represent previous commit. We check
 ## the style of changes between current head and previous commit after a commit
 ## is rewritten.
-git diff --name-only --diff-filter=AM @~..@ | xargs ./support/mesos-style.py || exit 1
+ADDED_OR_MODIFIED=$(git diff --name-only --diff-filter=AM @~..@)
+if [ "$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/mesos-style.py $ADDED_OR_MODIFIED || exit 1
+fi
 
 # Check that the commits are properly split between mesos, libprocess and stout.
 ## In git, '@' represent current head, '@~' represent previous commit. We check

http://git-wip-us.apache.org/repos/asf/mesos/blob/46d559fe/support/hooks/pre-commit
----------------------------------------------------------------------
diff --git a/support/hooks/pre-commit b/support/hooks/pre-commit
index ca9e981..bdc12af 100755
--- a/support/hooks/pre-commit
+++ b/support/hooks/pre-commit
@@ -24,7 +24,17 @@ exec 1>&2
 git diff-index --check --cached $against -- || exit 1
 
 # Check Mesos style.
-git diff --cached --name-only --diff-filter=AM | xargs ./support/mesos-style.py || exit 1
+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/mesos-style.py $ADDED_OR_MODIFIED || exit 1
+fi
 
 # Check that the commits are properly split between mesos, libprocess and stout.
 git diff --cached --name-only --diff-filter=AMD | xargs ./support/mesos_split.py || exit 1