diff options
author | David Cole <david.cole@kitware.com> | 2012-07-24 21:02:09 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-07-24 21:02:09 (GMT) |
commit | 17cb00e5dc5e6da85b6c33f5bf495ffae6f8af4a (patch) | |
tree | a1a8f30852b49d087d473c34dc611451ca1a5eda /Utilities | |
parent | 2b3a0dbeffc5368f1be7e425658d5162dbc0af7e (diff) | |
parent | 873f21ad1bcbf900025b7cbddb50b94b37d198aa (diff) | |
download | CMake-17cb00e5dc5e6da85b6c33f5bf495ffae6f8af4a.zip CMake-17cb00e5dc5e6da85b6c33f5bf495ffae6f8af4a.tar.gz CMake-17cb00e5dc5e6da85b6c33f5bf495ffae6f8af4a.tar.bz2 |
Merge topic 'hooks-line-length'
873f21a pre-commit: Reject C++ code with lines too long
Diffstat (limited to 'Utilities')
-rwxr-xr-x | Utilities/Git/pre-commit | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Utilities/Git/pre-commit b/Utilities/Git/pre-commit index 110e9ee..d308a81 100755 --- a/Utilities/Git/pre-commit +++ b/Utilities/Git/pre-commit @@ -19,6 +19,26 @@ die() { 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) && |