From: Jean Privat Date: Wed, 19 Aug 2015 06:55:14 +0000 (-0400) Subject: jenkins: improve checklicense to be more explicit and friendly X-Git-Tag: v0.7.8~84^2~3 X-Git-Url: http://nitlanguage.org jenkins: improve checklicense to be more explicit and friendly Signed-off-by: Jean Privat --- diff --git a/misc/jenkins/checklicense.sh b/misc/jenkins/checklicense.sh index 3fcd8af..16f5260 100755 --- a/misc/jenkins/checklicense.sh +++ b/misc/jenkins/checklicense.sh @@ -14,19 +14,33 @@ # limitations under the License. # Check missing "This file is part of NIT…" comment in committed scripts. +# +# Usage: checklicense.sh from to -if test "$#" -lt 2; then - echo "Usage: checklicense from to" - echo "" - exit -fi +set -e -from=$1 -to=$2 +from=${1:-origin/master} +to=${2:-HEAD} err=0 +cd `git rev-parse --show-toplevel` + +echo "checklicense $from (`git rev-parse "$from"`) .. $to (`git rev-parse "$to"`)" git diff --name-status $from..$to -- "*.nit" "*.sh" | sed -n 's/^A\s*//p' > checklicense_new_files.out -test -s checklicense_new_files.out || exit 0 -grep -L '\(^\|\b\)# [Tt]his file is part of NIT ' `cat checklicense_new_files.out` 2>/dev/null | tee checklicense_missing.out -test \! -s checklicense_missing.out +if test \! -s checklicense_new_files.out; then + echo "No new files" + exit 0 +fi +grep -L '\(^\|\b\)# [Tt]his file is part of NIT ' `cat checklicense_new_files.out` 2>/dev/null > checklicense_missing.out || true +if test -s checklicense_missing.out; then + echo "These files are missing their licence:" + echo "" + cat checklicense_missing.out + echo "" + echo "Please double check that the licence text (i.e. \`This file is part of NIT...\`) is included at the begin of these files." + exit 1 +else + echo "All `cat checklicense_new_files.out | wc -l` checked new files have a correct license." + exit 0 +fi