2 cd $(git rev-parse --show-toplevel)
4 export PATH=$PATH:$PWD/scripts
6 if [ -z "$TRAVIS_COMMIT_RANGE" ]; then
7 echo "No commit range given"
11 if ! type -p astyle.sh >/dev/null; then
12 echo astyle.sh not found
18 ASTYLEDIFF=/tmp/astyle.diff
22 if [[ ! -z $TRAVIS_PULL_REQUEST_BRANCH ]]; then
23 # if on a PR, just analyse the changed files
24 echo "TRAVIS PR BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
25 FILES=$(git diff --diff-filter=AM --name-only $(git merge-base HEAD master) | tr '\n' ' ' )
26 elif [[ ! -z $TRAVIS_COMMIT_RANGE ]]; then
27 echo "TRAVIS COMMIT RANGE: $TRAVIS_COMMIT_RANGE"
28 FILES=$(git diff --diff-filter=AM --name-only ${TRAVIS_COMMIT_RANGE/.../..} | tr '\n' ' ' )
32 if ! [ -f "$f" ]; then
33 echo "$f was removed." >>/tmp/ctest-important.log
37 echo "Checking $f" >>/tmp/ctest-important.log
44 *.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py)
55 if diff -u "$m" "$f" >>$ASTYLEDIFF; then
58 echo "File $f needs indentation"
62 if [ -s "$ASTYLEDIFF" ]; then
64 echo "Required indentation updates:"
69 Tips to prevent and resolve:
70 * Enable WITH_ASTYLE in your cmake configuration to format C++ code
71 * Install autopep8 (>= 1.2.1) to format python code
72 * Use "scripts/astyle.sh file" to fix the now badly indented files
73 * Consider using scripts/prepare-commit.sh as pre-commit hook to avoid this
74 in the future (ln -s scripts/prepare-commit.sh .git/hooks/pre-commit) or
75 run it manually before each commit.