Skip to content

Commit 2cd0b81

Browse files
committed
travis: astyle only on changed files in PR
1 parent 396fa5f commit 2cd0b81

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,16 @@ matrix:
105105
popd;
106106
- astyle --version
107107
script:
108-
- find -regex '.*\.\(h\|c\|hpp\|cpp\)' -type f | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle.out;
108+
# only changed files to be checked for astyle
109+
- COMMIT_RANGE=${TRAVIS_COMMIT_RANGE/.../..}
110+
- if [! git diff --quiet "$COMMIT_RANGE" -- ]
111+
then
112+
COMMIT_CONTENT=`git diff-tree --no-commit-id --name-only -r $TRAVIS_COMMIT`
113+
else
114+
COMMIT_CONTENT=`git diff --name-only $COMMIT_RANGE`
115+
fi
116+
- echo $COMMIT_CONTENT
117+
- find -regex '.*\.\(h\|c\|hpp\|cpp\)' -type f | fgrep -v -f .astyleignore | $COMMIT_CONTENT | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle.out;
109118
if [ $(cat astyle.out | grep Formatted | wc -l) -ne 0 ]; then
110119
git --no-pager diff;
111120
echo "Please fix style issues as shown above";

0 commit comments

Comments
 (0)