@@ -22,7 +22,7 @@ if ! tty -s && [[ "$0" =~ /pre-commit ]]; then
exec < /dev/tty
fi
cd $TOPLEVEL
cd " $TOPLEVEL "
# GNU prefix command for mac os support (gsed, gsplit)
GP=
@@ -57,25 +57,25 @@ if [ -z "$MODIFIED" ]; then
exit 0
fi
if [[ -n " $QGIS_CHECK_SPELLING " && -x ${TOPLEVEL} /scripts/spell_check/check_spelling.sh ]]; then ${TOPLEVEL} /scripts/spell_check/check_spelling.sh $MODIFIED ; fi
if [[ -n " $QGIS_CHECK_SPELLING " && -x " ${TOPLEVEL} " /scripts/spell_check/check_spelling.sh ]]; then " ${TOPLEVEL} " /scripts/spell_check/check_spelling.sh " $MODIFIED " ; fi
# save original changes
REV=$( git log -n1 --pretty=%H)
git diff > sha-$REV .diff
git diff > sha-" $REV " .diff
ASTYLEDIFF=astyle.$REV .diff
true > $ASTYLEDIFF
true > " $ASTYLEDIFF "
# reformat
i=0
N=$( echo $MODIFIED | wc -w)
N=$( echo " $MODIFIED " | wc -w)
for f in $MODIFIED ; do
(( i++ )) || true
case " $f " in
src/core/gps/qextserialport/* |src/plugins/globe/osgEarthQt/* |src/plugins/globe/osgEarthUtil/* |src/3d/poly2tri/* )
echo $f skipped
echo " $f " skipped
continue
;;
@@ -89,59 +89,59 @@ for f in $MODIFIED; do
m=$f .$REV .prepare
cp $f $m
ASTYLEPROGRESS=" [$i /$N ]" astyle.sh $f
if diff -u $m $f >> $ASTYLEDIFF ; then
cp " $f " " $m "
ASTYLEPROGRESS=" [$i /$N ]" astyle.sh " $f "
if diff -u " $m " " $f " >> " $ASTYLEDIFF " ; then
# no difference found
rm $m
rm " $m "
fi
done
if [ -s " $ASTYLEDIFF " ]; then
if tty -s; then
# review astyle changes
colordiff < $ASTYLEDIFF | less -r
colordiff < " $ASTYLEDIFF " | less -r
else
echo " Files changed (see $ASTYLEDIFF )"
fi
else
rm $ASTYLEDIFF
rm " $ASTYLEDIFF "
fi
# verify SIP files
SIPIFYDIFF=sipify.$REV .diff
true > $SIPIFYDIFF
true > " $SIPIFYDIFF "
for f in $MODIFIED ; do
# if cpp header
if [[ $f =~ ^src\/ (core| gui| analysis| server)\/ .* \. h$ ]]; then
# look if corresponding SIP file
sip_file=$( ${GP} sed -r ' s@^src/(core|gui|analysis|server)/@@; s@\.h$@.sip@' <<< $f )
pyfile=$( ${GP} sed -E ' s@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< $sip_file )
module=$( ${GP} sed -r ' s@src/(core|gui|analysis|server)/.*$@\1@' <<< $f )
if grep -Fq " $sip_file " ${TOPLEVEL} /python/${module} / ${module} _auto.sip; then
sip_file=$( ${GP} sed -r ' s@^src/(core|gui|analysis|server)@\1/auto_generated@; s@\.h$@.sip.in@' <<< $f )
sip_file=$( ${GP} sed -r ' s@^src/(core|gui|analysis|server)/@@; s@\.h$@.sip@' <<< " $f " )
pyfile=$( ${GP} sed -E ' s@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< " $sip_file" )
module=$( ${GP} sed -r ' s@src/(core|gui|analysis|server)/.*$@\1@' <<< " $f " )
if grep -Fq " $sip_file " " ${TOPLEVEL} " /python/" ${module} " / " ${module} " _auto.sip; then
sip_file=$( ${GP} sed -r ' s@^src/(core|gui|analysis|server)@\1/auto_generated@; s@\.h$@.sip.in@' <<< " $f " )
m=python/$sip_file .$REV .prepare
touch python/$sip_file
cp python/$sip_file $m
${TOPLEVEL} /scripts/sipify.pl -s python/$sip_file -p python/${module} /auto_additions/${pyfile} $f
if ! diff -u $m python/$sip_file >> $SIPIFYDIFF ; then
touch python/" $sip_file "
cp python/" $sip_file " " $m "
" ${TOPLEVEL} " /scripts/sipify.pl -s python/" $sip_file " -p python/" ${module} " /auto_additions/" ${pyfile} " " $f "
if ! diff -u " $m " python/" $sip_file " >> " $SIPIFYDIFF " ; then
echo " python/$sip_file is not up to date"
fi
rm $m
rm " $m "
fi
fi
done
if [[ -s " $SIPIFYDIFF " ]]; then
if tty -s; then
# review astyle changes
colordiff < $SIPIFYDIFF | less -r
colordiff < " $SIPIFYDIFF " | less -r
else
echo " Files changed (see $ASTYLEDIFF )"
fi
exit 1
else
rm $SIPIFYDIFF
rm " $SIPIFYDIFF "
fi
if [ -s " $ASTYLEDIFF " ]; then
exit 1