Skip to content

Commit

Permalink
add indentation update script
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9188 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Aug 27, 2008
1 parent a434ac6 commit 70cf91a
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions scripts/update-indent.sh
@@ -0,0 +1,61 @@
#!/bin/bash

if ! [ -x astyle.sh ]; then
PATH=$PATH:$(dirname $0)
fi

set -e

# determine last commit
REV0=$(svn info | sed -ne "s/Revision: //p")

# update
MODIFIED=$(svn update | sed -ne "s/^[^ ]* *//p")
REV1=$(svn info | sed -ne "s/Revision: //p")

if [ "$REV0" -eq "$REV1" ]; then
echo "No activity since last run."
exit 0
fi

echo "Checking changes between $REV0 and $REV1"

ASTYLEDIFF=astyle.r$REV0-r$REV1.diff
>$ASTYLEDIFF


# reformat
for f in $MODIFIED; do
case "$f" in
*.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H)
;;

*)
continue
;;
esac

m=$f.r$REV1.prepare

cp $f $m
astyle.sh $f
if diff -u $m $f >>$ASTYLEDIFF; then
# no difference found
rm $m
fi
done

if [ -s "$ASTYLEDIFF" ]; then
if tty -s; then
# review astyle changes
colordiff <$ASTYLEDIFF | less -r
else
echo "Files changed (see $ASTYLEDIFF)"
fi

# just echo for now
echo svn commit -m "automatic indentation update (r$REV0-r$REV1)"
else
echo "No indentation updates."
rm $ASTYLEDIFF
fi

0 comments on commit 70cf91a

Please sign in to comment.