Merge topic 'lfs-setup-fixups'

bea0a7e38 hooks: add hook chains for development checks and LFS
867f0a069 SetupForDevelopment: setup lfs hooks
4da3a3dc3 Merge branch 'upstream-GitSetup' into lfs-setup-fixups
7d2569485 GitSetup 2018-06-26 (1ed3dc31)
8b3fa1d61 gitsetup: get the lfs setup script
eadc9b8f3 cmake: unset launcers if testing is disabled

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !2026
This commit is contained in:
Ben Boeckel 2020-04-02 18:57:04 +00:00 committed by Kitware Robot
commit 65fb96dfcf
8 changed files with 91 additions and 5 deletions

6
.hooks-config Normal file

@ -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

@ -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()
#-----------------------------------------------------------------------------

@ -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 ;;

41
Utilities/GitSetup/setup-lfs Executable file

@ -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 <https://git-lfs.github.com>.'
fi

@ -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}

24
Utilities/hooks/pre-commit Executable file

@ -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

3
Utilities/hooks/pre-push Executable file

@ -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 "$@"

@ -18,6 +18,7 @@ README
git-gitlab-push
setup-gitlab
setup-hooks
setup-lfs
setup-ssh
setup-upstream
setup-user