Skip to content

Commit d975240

Browse files
author
jef
committed
add script to prepare changed files with astyle for commit
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9149 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2acd927 commit d975240

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

scripts/prepare-commit.sh

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
if ! [ -x astyle.sh ]; then
4+
PATH=$PATH:$(dirname $0)
5+
fi
6+
7+
set -e
8+
9+
# determine changed files
10+
MODIFIED=$(svn status | sed -ne "s/^[MA] *//p")
11+
12+
if [ -z "$MODIFIED" ]; then
13+
echo nothing was modified
14+
exit 1
15+
fi
16+
17+
# save original changes
18+
REV=$(svn info | sed -ne "s/Revision: //p")
19+
svn diff >r$REV.diff
20+
21+
ASTYLEDIFF=astyle.r$REV.diff
22+
>$ASTYLEDIFF
23+
24+
# reformat
25+
for f in $MODIFIED; do
26+
case "$f" in
27+
*.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H)
28+
;;
29+
30+
*)
31+
continue
32+
;;
33+
esac
34+
35+
m=$f.r$REV.prepare
36+
37+
cp $f $m
38+
astyle.sh $f
39+
if diff -u $m $f >>$ASTYLEDIFF; then
40+
# no difference found
41+
rm $m
42+
fi
43+
done
44+
45+
if [ -s "$ASTYLEDIFF" ]; then
46+
if tty -s; then
47+
# review astyle changes
48+
colordiff <$ASTYLEDIFF | less -r
49+
else
50+
echo "Files changed (see $ASTYLEDIFF)"
51+
fi
52+
else
53+
rm $ASTYLEDIFF
54+
fi

0 commit comments

Comments
 (0)