From 5f6611356ef106042fbc1a5dd3de167875a22ba6 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 5 Apr 2012 16:50:37 +0100 Subject: [PATCH] ENH: pre-commit-hook: abort upon bad date. --- bin/tools/pre-commit-hook | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook index 1a8ae0181ad..551af76c6ce 100755 --- a/bin/tools/pre-commit-hook +++ b/bin/tools/pre-commit-hook @@ -275,6 +275,7 @@ checkCopyright() year=$(date +%Y) echo "$hookName: check copyright ..." 1>&2 + badFiles=$( for f in $fileList do startYear=`grep "Copyright.*OpenFOAM" $f | sed 's/[^0-9]*\([0-9]*\).*/\1/g'` @@ -287,19 +288,24 @@ checkCopyright() # Date is of type 2011-2012 OpenFOAM Foundation if [ "$year" != "$endYear" ] then - echo "Updated copyright for: $f" + echo "Updated copyright for: $f" 1>&2 + echo "$f" sed -i "s/$startYear-$endYear OpenFOAM/$startYear-$year OpenFOAM/g" $f fi else # Date is of type 2011 OpenFOAM Foundation if [ "$year" != "$startYear" ] then - echo "Updated copyright for: $f" + echo "$f" + echo "Updated copyright for: $f" 1>&2 sed -i "s/$startYear OpenFOAM/$startYear-$year OpenFOAM/g" $f fi fi fi done + ) + + dieOnBadFiles "Some copyright dates were automatically updated; Please check these before pushing" } -- GitLab