diff --git a/.hooks-config b/.hooks-config new file mode 100644 index 000000000..5fe63d350 --- /dev/null +++ b/.hooks-config @@ -0,0 +1,6 @@ +# Loaded by .git/hooks/(pre-commit|commit-msg|prepare-commit-msg) +# during git commit after local hooks have been installed. + +[hooks "chain"] + pre-commit = utilities/git/pre-commit + pre-push = utilities/git/pre-push diff --git a/CMakeLists.txt b/CMakeLists.txt index d535de68e..7a77cbf39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,9 +167,6 @@ if (NOT data STREQUAL "\n") "Testing is enabled, but the data is not available. Use git lfs in order " " to obtain the testing data.") set(VTKm_ENABLE_TESTING off) - if (CTEST_USE_LAUNCHERS) - set(CTEST_USE_LAUNCHERS off) - endif() endif() # We include the wrappers unconditionally as VTK-m expects the function to @@ -340,6 +337,8 @@ if (VTKm_ENABLE_TESTING) # installed version of VTK-m. include(testing/VTKmTestInstall) vtkm_test_install() +else () + set(CTEST_USE_LAUNCHERS off) endif() #----------------------------------------------------------------------------- diff --git a/Utilities/GitSetup/git-gitlab-push b/Utilities/GitSetup/git-gitlab-push index a7128cecd..ae33ac8a1 100755 --- a/Utilities/GitSetup/git-gitlab-push +++ b/Utilities/GitSetup/git-gitlab-push @@ -23,7 +23,8 @@ OPTIONS Show what would be pushed without actually updating the destination -f,--force - Force-push the topic HEAD to rewrite the destination branch + Force-push the topic HEAD to rewrite the destination branch (use twice + to ignore stale remote tracking branches) --no-default Do not push the default branch (e.g. master) @@ -73,7 +74,14 @@ set_upstream=true # Parse the command line options. while test $# != 0; do case "$1" in - -f|--force) force='+'; lease=true ;; + -f|--force) + if test -n "$force"; then + lease=false + else + lease=true + fi + force='+' + ;; --no-topic) no_topic=1; set_upstream=false ;; --dry-run) dry_run=--dry-run ;; --no-default) no_default=1 ;; diff --git a/Utilities/GitSetup/setup-lfs b/Utilities/GitSetup/setup-lfs new file mode 100755 index 000000000..1ee6d3b19 --- /dev/null +++ b/Utilities/GitSetup/setup-lfs @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +#============================================================================= +# Copyright 2017 Kitware, Inc. +# +# Licensed 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. +#============================================================================= + +# Run this script to set up the local Git repository to push LFS data to +# remotes. + +die() { + echo 1>&2 "$@" ; exit 1 +} + +# Make sure we are inside the repository. +cd "${BASH_SOURCE%/*}" && + +# Set the LFS filter configuration up. +if git lfs version; then + git config filter.lfs.clean "git-lfs clean -- %f" && + git config filter.lfs.smudge "git-lfs smudge -- %f" && + git config filter.lfs.process "git-lfs filter-process" && + git config filter.lfs.required true && + git lfs fetch && + git lfs checkout && + echo 'LFS is now configured.' +else + die 'Git LFS is not available. Please make it available on the PATH' \ + 'either by installing it through your system provider or installing it' \ + 'from .' +fi diff --git a/Utilities/SetupForDevelopment.sh b/Utilities/SetupForDevelopment.sh index 651fc6faf..720a7d974 100755 --- a/Utilities/SetupForDevelopment.sh +++ b/Utilities/SetupForDevelopment.sh @@ -3,6 +3,7 @@ cd "${BASH_SOURCE%/*}/.." && Utilities/GitSetup/setup-user && echo && Utilities/GitSetup/setup-hooks && echo && +Utilities/GitSetup/setup-lfs && echo && (Utilities/GitSetup/setup-upstream || echo 'Failed to setup origin. Run this again to retry.') && echo && (Utilities/GitSetup/setup-gitlab || @@ -27,3 +28,6 @@ echo "Set up git gitlab-push" && git config alias.gitlab-sync '!bash Utilities/GitSetup/git-gitlab-sync' && echo "Set up git gitlab-sync" && true + +SetupForDevelopment=1 +git config hooks.SetupForDevelopment ${SetupForDevelopment_VERSION} diff --git a/Utilities/hooks/pre-commit b/Utilities/hooks/pre-commit new file mode 100755 index 000000000..2df9e7620 --- /dev/null +++ b/Utilities/hooks/pre-commit @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +die() { + echo 'pre-commit hook failure' 1>&2 + echo '-----------------------' 1>&2 + echo '' 1>&2 + echo "$@" 1>&2 + exit 1 +} + +#----------------------------------------------------------------------------- + +# Check that development setup is up-to-date. +lastSetupForDevelopment=$(git config --get hooks.SetupForDevelopment || echo 0) +eval $(grep '^SetupForDevelopment_VERSION=' "${BASH_SOURCE%/*}/../SetupForDevelopment.sh") +test -n "$SetupForDevelopment_VERSION" || SetupForDevelopment_VERSION=0 +if test $lastSetupForDevelopment -lt $SetupForDevelopment_VERSION; then + die 'Developer setup in this work tree is out of date. Please re-run + + Utilities/SetupForDevelopment.sh +' +fi diff --git a/Utilities/hooks/pre-push b/Utilities/hooks/pre-push new file mode 100755 index 000000000..e930f484f --- /dev/null +++ b/Utilities/hooks/pre-push @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path.\n"; exit 2; } +git lfs pre-push "$@" diff --git a/Utilities/update-gitsetup.bash b/Utilities/update-gitsetup.bash index 3644d8aea..b8b3bbe0f 100755 --- a/Utilities/update-gitsetup.bash +++ b/Utilities/update-gitsetup.bash @@ -18,6 +18,7 @@ README git-gitlab-push setup-gitlab setup-hooks +setup-lfs setup-ssh setup-upstream setup-user