Skip to content
Snippets Groups Projects
Commit 5f661135 authored by mattijs's avatar mattijs
Browse files

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

parent 31977f8f
Branches
Tags
No related merge requests found
...@@ -275,6 +275,7 @@ checkCopyright() ...@@ -275,6 +275,7 @@ checkCopyright()
year=$(date +%Y) year=$(date +%Y)
echo "$hookName: check copyright ..." 1>&2 echo "$hookName: check copyright ..." 1>&2
badFiles=$(
for f in $fileList for f in $fileList
do do
startYear=`grep "Copyright.*OpenFOAM" $f | sed 's/[^0-9]*\([0-9]*\).*/\1/g'` startYear=`grep "Copyright.*OpenFOAM" $f | sed 's/[^0-9]*\([0-9]*\).*/\1/g'`
...@@ -287,19 +288,24 @@ checkCopyright() ...@@ -287,19 +288,24 @@ checkCopyright()
# Date is of type 2011-2012 OpenFOAM Foundation # Date is of type 2011-2012 OpenFOAM Foundation
if [ "$year" != "$endYear" ] if [ "$year" != "$endYear" ]
then 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 sed -i "s/$startYear-$endYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
fi fi
else else
# Date is of type 2011 OpenFOAM Foundation # Date is of type 2011 OpenFOAM Foundation
if [ "$year" != "$startYear" ] if [ "$year" != "$startYear" ]
then 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 sed -i "s/$startYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
fi fi
fi fi
fi fi
done done
)
dieOnBadFiles "Some copyright dates were automatically updated; Please check these before pushing"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment