Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script to prepare changed files with astyle for commit
git-svn-id: http://svn.osgeo.org/qgis/trunk@9149 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
jef
committed
Aug 24, 2008
1 parent
4875071
commit f3fd51c
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
if ! [ -x astyle.sh ]; then | ||
PATH=$PATH:$(dirname $0) | ||
fi | ||
|
||
set -e | ||
|
||
# determine changed files | ||
MODIFIED=$(svn status | sed -ne "s/^[MA] *//p") | ||
|
||
if [ -z "$MODIFIED" ]; then | ||
echo nothing was modified | ||
exit 1 | ||
fi | ||
|
||
# save original changes | ||
REV=$(svn info | sed -ne "s/Revision: //p") | ||
svn diff >r$REV.diff | ||
|
||
ASTYLEDIFF=astyle.r$REV.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$REV.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 | ||
else | ||
rm $ASTYLEDIFF | ||
fi |