#!/bin/bash cd $(git rev-parse --show-toplevel) export PATH=$PATH:$PWD/scripts if [ -z "$TRAVIS_COMMIT_RANGE" ]; then echo "No commit range given" exit 0 fi TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE/.../..} if ! type -p astyle.sh >/dev/null; then echo astyle.sh not found exit 1 fi set -e ASTYLEDIFF=/tmp/astyle.diff >$ASTYLEDIFF echo "Checking indentation in $TRAVIS_COMMIT_RANGE" echo "Checking indentation in $TRAVIS_COMMIT_RANGE" >>/tmp/ctest-important.log git log $TRAVIS_COMMIT_RANGE >>/tmp/ctest-important.log 2>&1 git diff --name-only $TRAVIS_COMMIT_RANGE >>/tmp/ctest-important.log 2>&1 git diff --name-only $TRAVIS_COMMIT_RANGE | while read f do echo "Checking $f" >>/tmp/ctest-important.log case "$f" in src/core/gps/qextserialport/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*) echo $f skipped continue ;; *.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py) ;; *) continue ;; esac m=$f.prepare cp "$f" "$m" astyle.sh "$f" if diff -u "$m" "$f" >>$ASTYLEDIFF; then rm $m else echo "File $f needs indentation" fi done if [ -s "$ASTYLEDIFF" ]; then echo echo "Required indentation updates:" cat "$ASTYLEDIFF" cat <