ENH: pre-commit-hook: abort upon bad date.

This commit is contained in:
mattijs
2012-04-05 16:50:37 +01:00
parent 31977f8f9b
commit 5f6611356e

View File

@ -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"
}