CMake/Utilities/Git/pre-commit
Brad King 56a687d173 Merge topic 'import-KWSys-subtree'
68579cd Merge branch 'upstream-kwsys' into import-KWSys-subtree
cd83da9 KWSys 2012-11-05 (df32fa6f)
3517106 CTestCustom: Suppress LNK4089 warning about PSAPI
5c63fa3 Merge branch 'ctest-SUBMIT_INDEX-cdash' into import-KWSys-subtree
17fb60b Merge branch 'upstream-kwsys' into import-KWSys-subtree
7ae44db KWSys 2012-10-16 (b7a97ac3)
97c9887 pre-commit: Update KWSys rejection message for new workflow
3db0b51 KWSys: Submit dashboard builds to PublicDashboard
4b8d363 Merge branch 'upstream-kwsys' into import-KWSys-subtree
a61f633 Merge branch 'master' into import-KWSys-subtree
8c55ea0 Merge branch 'upstream-kwsys' into import-KWSys-subtree
5d0de36 KWSys 2012-10-01 (bab53989)
7d3c295 KWSys 2012-05-02 (719638e2)
2012-11-07 09:07:15 -05:00

66 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#=============================================================================
# CMake - Cross Platform Makefile Generator
# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
die() {
echo 'pre-commit hook failure' 1>&2
echo '-----------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
}
#-------------------------------------------------------------------------------
line_too_long=80
bad=$(regex=".{$line_too_long}" &&
git diff-index --cached HEAD --name-only --diff-filter=AM \
--pickaxe-regex -S"$regex" -- 'Source/*.h' 'Source/*.cxx' |
while read file; do
lines_too_long=$(git diff-index -p --cached HEAD \
--pickaxe-regex -S"$regex" -- "$file")
if echo "$lines_too_long" | egrep -q '^\+'"$regex"; then
echo "$lines_too_long"
fi
done)
test -z "$bad" ||
die 'The following changes add lines too long for our C++ style:
'"$bad"'
Use lines strictly less than '"$line_too_long"' characters in C++ code.'
#-------------------------------------------------------------------------------
if test -z "$HOOKS_ALLOW_KWSYS"; then
# Disallow changes to KWSys
files=$(git diff-index --name-only --cached HEAD -- Source/kwsys) &&
if test -n "$files"; then
die 'Changes to KWSys files
'"$(echo "$files" | sed 's/^/ /')"'
should not be made directly in CMake. KWSys is kept in its own Git
repository and shared by several projects. Please visit
http://public.kitware.com/Wiki/KWSys/Git
to contribute changes directly to KWSys. Run
git reset HEAD -- Source/kwsys
to unstage these changes. Alternatively, set environment variable
HOOKS_ALLOW_KWSYS=1
to disable this check and commit the changes locally.'
fi
fi