[QGIS Commit] r9149 - trunk/qgis/scripts
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Aug 24 09:57:54 EDT 2008
Author: jef
Date: 2008-08-24 09:57:54 -0400 (Sun, 24 Aug 2008)
New Revision: 9149
Added:
trunk/qgis/scripts/prepare-commit.sh
Log:
add script to prepare changed files with astyle for commit
Added: trunk/qgis/scripts/prepare-commit.sh
===================================================================
--- trunk/qgis/scripts/prepare-commit.sh (rev 0)
+++ trunk/qgis/scripts/prepare-commit.sh 2008-08-24 13:57:54 UTC (rev 9149)
@@ -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
Property changes on: trunk/qgis/scripts/prepare-commit.sh
___________________________________________________________________
Name: svn:executable
+ *
More information about the QGIS-commit
mailing list