mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
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
This commit is contained in:
parent
4875071741
commit
f3fd51cab5
54
scripts/prepare-commit.sh
Executable file
54
scripts/prepare-commit.sh
Executable file
@ -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
|
Loading…
x
Reference in New Issue
Block a user