MRG: Initial commit after latest Foundation merge

This commit is contained in:
Andrew Heather
2016-09-30 11:16:28 +01:00
1177 changed files with 5472 additions and 1421 deletions

View File

@ -3,8 +3,8 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
# \\/ M anipulation |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -48,11 +48,14 @@
# test the specified files/directories for standards conformance.
#
#------------------------------------------------------------------------------
hookName="pre-commit"
headerSeparator="-----------------------------------"
die()
{
echo "$hookName hook failure" 1>&2
echo '-----------------------------------' 1>&2
echo $headerSeparator 1>&2
echo '' 1>&2
echo "$@" 1>&2
echo '' 1>&2
@ -105,7 +108,7 @@ dieOnBadFiles()
if [ -n "$badFiles" ]
then
echo "$hookName hook failure" 1>&2
echo '-----------------------------------' 1>&2
echo $headerSeparator 1>&2
echo "$@" 1>&2
echo '' 1>&2
echo "File(s):" 1>&2
@ -267,6 +270,49 @@ checkLineLengthNonDirective()
}
#
# check for non-standard code patterns
#
checkNonStandardCodePatterns()
{
echo "$hookName: checking for non-standard code ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# limit to *.[CH] files
case "$f" in
(*.[CH])
# Directly report the incorrect markers
git grep -n --color \
-e '> >' -e '\bNULL\b' \
$scope"$f"
;;
esac
done
)
dieOnBadFiles "$(cat<<MESSAGE
Please revise the files reported below for the following non-standard code:
1. Spaced ending of multi-level template parameters are not allowed, such as:
List<List<scalar> >
which instead should be:
List<List<scalar>>
2. The use of the 'NULL' macro should be replaced by 'nullptr'
$headerSeparator
MESSAGE
)"
}
#
# check that OpenFOAM Foundation copyright is current
#
@ -278,27 +324,27 @@ checkCopyright()
badFiles=$(
for f in $fileList
do
startYear=`grep "Copyright.*OpenFOAM" $f | sed 's/[^0-9]*\([0-9]*\).*/\1/g'`
endYear=`grep "Copyright.*-.*OpenFOAM" $f | sed 's/[^-]*-\([0-9]*\).*/\1/g'`
startYear=`grep "Copyright.*OpenCFD" $f | sed 's/[^0-9]*\([0-9]*\).*/\1/g'`
endYear=`grep "Copyright.*-.*OpenCFD" $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
# Date is of type 2011-2012 OpenCFD Ltd.
if [ "$year" != "$endYear" ]
then
echo "Updated copyright for: $f" 1>&2
echo "$f"
sed -i -e "s/$startYear-$endYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
sed -i -e "s/$startYear-$endYear OpenCFD/$startYear-$year OpenCFD/g" $f
fi
else
# Date is of type 2011 OpenFOAM Foundation
# Date is of type 2011 OpenCFD Ltd.
if [ "$year" != "$startYear" ]
then
echo "$f"
echo "Updated copyright for: $f" 1>&2
sed -i -e "s/$startYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
sed -i -e "s/$startYear OpenCFD/$startYear-$year OpenCFD/g" $f
fi
fi
fi
@ -322,6 +368,9 @@ checkIllegalCode
# ensure code conforms to 80 columns max
checkLineLengthNonDirective
# check for non-standard code patterns
checkNonStandardCodePatterns
checkCopyright
exit 0