From: Jean Privat Date: Wed, 19 Aug 2015 06:56:36 +0000 (-0400) Subject: jenkins: add checkwhitespace to be a more explicit and friendly `git log --check` X-Git-Tag: v0.7.8~84^2~1 X-Git-Url: http://nitlanguage.org jenkins: add checkwhitespace to be a more explicit and friendly `git log --check` Signed-off-by: Jean Privat --- diff --git a/misc/jenkins/checkwhitespaces.sh b/misc/jenkins/checkwhitespaces.sh new file mode 100755 index 0000000..32a9aab --- /dev/null +++ b/misc/jenkins/checkwhitespaces.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# 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. + +# Check whitespace errors in commits +# Usage: checkwhitespaces from to +# +# This script is in fact a more friendly version of `git log --check` + +set -e + +from=${1:-origin/master} +to=${2:-HEAD} + +err=0 + +cd `git rev-parse --show-toplevel` + +echo "checkwhitespaces $from (`git rev-parse "$from"`) .. $to (`git rev-parse "$to"`)" +for ref in `git rev-list --no-merges "$from".."$to"`; do + # Show nothing if no error + if git --no-pager show --check --oneline $ref > /dev/null; then + continue + fi + + # Run the command again to display things + echo "" + echo "Found whitespace errors in commit" + git --no-pager show --check --oneline $ref || true + err=1 +done + +if test "$err" = 1; then + echo "" + echo "Please check that each file in each commit does not contain whitespace errors." + echo "Note that existing commits should be amended; pushing new commit is not sufficient." + echo "Hint: use \"git log --check\" to see whitespace errors." +fi + +exit $err