From 09eac90233858af6b62ff69bd2d1d8879f098b03 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Fri, 3 Feb 2012 14:38:02 +0000 Subject: [PATCH] ENH: pre-commit-hook: update copyright date checking --- bin/tools/pre-commit-hook | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook index 01ea8faaaf3..1a8ae0181ad 100755 --- a/bin/tools/pre-commit-hook +++ b/bin/tools/pre-commit-hook @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -268,7 +268,7 @@ checkLineLengthNonDirective() # -# check that OpenFOAM Foundation copyright is currents +# check that OpenFOAM Foundation copyright is current # checkCopyright() { @@ -277,12 +277,28 @@ checkCopyright() for f in $fileList do - sYear=`grep "Copyright.*OpenFOAM" $f | sed 's/[^0-9]//g'` - if [ "$sYear" != "" ] && [ "$year" != "$sYear" ]; then - echo "Updated copyright for: $f" - sed -i "s/$sYear OpenFOAM/$year OpenFOAM/g" $f + startYear=`grep "Copyright.*OpenFOAM" $f | sed 's/[^0-9]*\([0-9]*\).*/\1/g'` + endYear=`grep "Copyright.*-.*OpenFOAM" $f | sed 's/[^-]*-\([0-9]*\).*/\1/g'` + #echo "startYear=$startYear endYear=$endYear" + if [ "$startYear" != "" ] + then + if [ "$endYear" != "" ] + then + # Date is of type 2011-2012 OpenFOAM Foundation + if [ "$year" != "$endYear" ] + then + echo "Updated copyright for: $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" + sed -i "s/$startYear OpenFOAM/$startYear-$year OpenFOAM/g" $f + fi + fi fi - done } -- GitLab