mirror of https://github.com/ARMmbed/mbed-os.git
travis: add astyle run for all changes in the PR
To compare to master, use entire branch, not only files changed.pull/6590/head
parent
6d427eaea1
commit
c12ee10c5d
11
.travis.yml
11
.travis.yml
|
@ -105,18 +105,21 @@ matrix:
|
||||||
popd;
|
popd;
|
||||||
- astyle --version
|
- astyle --version
|
||||||
script:
|
script:
|
||||||
# only changed files to be checked for astyle
|
# only changed files this time
|
||||||
- git diff --name-only $TRAVIS_BRANCH | grep '.*\.\(h\|c\|hpp\|cpp\)' | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle.out;
|
- git diff --name-only $TRAVIS_BRANCH | grep '.*\.\(h\|c\|hpp\|cpp\)' | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-files-changed.out;
|
||||||
if [ $(cat astyle.out | grep Formatted | wc -l) -ne 0 ]; then
|
if [ $(cat astyle-files-changed.out | grep Formatted | wc -l) -ne 0 ]; then
|
||||||
git --no-pager diff;
|
git --no-pager diff;
|
||||||
echo "Please fix style issues as shown above";
|
echo "Please fix style issues as shown above";
|
||||||
else
|
else
|
||||||
echo "Coding style check OK";
|
echo "Coding style check OK";
|
||||||
fi
|
fi
|
||||||
after_success:
|
after_success:
|
||||||
|
# run astyle for all files on the branch
|
||||||
|
- git checkout -- .
|
||||||
|
- find -regex '.*\.\(h\|c\|hpp\|cpp\)' -type f | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-branch.out;
|
||||||
# update status if we succeeded, compare with master if possible
|
# update status if we succeeded, compare with master if possible
|
||||||
- |
|
- |
|
||||||
CURR=$(cat astyle.out | grep Formatted | wc -l)
|
CURR=$(cat astyle-branch.out | grep Formatted | wc -l)
|
||||||
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
|
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
|
||||||
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
|
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
|
||||||
| .statuses[] | select(.context == \"travis-ci/$NAME\").description
|
| .statuses[] | select(.context == \"travis-ci/$NAME\").description
|
||||||
|
|
Loading…
Reference in New Issue