Skip to content

Commit d6c42f7

Browse files
Cruz Monrreal IIMirela Chirica
authored andcommitted
Fix travis by cherry pick commit 84469e1
Corrected simplified astyle job behavior when base branch is not master Consolidated efforts from PR #9336. Previous job's env vars would not be populated correctly if the base branch of a PR was not master. Corected by pulling remaining respository information to perform comparison between read-only instance of PR and base branch.
1 parent a832c9c commit d6c42f7

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

.travis.yml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,29 +127,16 @@ matrix:
127127
export PATH=$PWD/bin:$PATH;
128128
popd;
129129
- astyle --version
130+
# Fetch remaining information needed for branch comparison
131+
- git fetch --all --unshallow --tags
132+
- git fetch origin "${TRAVIS_BRANCH}"
130133
script:
131-
# only changed files this time
132-
git diff --name-only --diff-filter=d $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;
133-
if [ $(cat astyle-files-changed.out | grep Formatted | wc -l) -ne 0 ]; then
134-
git --no-pager diff;
135-
echo "";
136-
echo "AStyle check failed, please fix style issues as shown above";
137-
(exit 1);
138-
else
139-
echo "Coding style check OK";
140-
fi
141-
after_success:
142-
# run astyle for all files on the branch
143-
- git checkout -- .
144-
- 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;
145-
# update status if we succeeded, compare with master if possible
146-
- |
147-
CURR=$(cat astyle-branch.out | grep Formatted | wc -l)
148-
PREV=$(curl -u "$MBED_BOT" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
149-
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
150-
| .statuses[] | select(.context == \"travis-ci/$NAME\").description
151-
| capture(\", (?<files>[0-9]+) files\").files" \
152-
|| echo 0)
134+
- >-
135+
git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
136+
| ( grep '.\(c\|cpp\|h\|hpp\)$' || true ) \
137+
| ( fgrep -v -f .astyleignore || true ) \
138+
| while read file; do astyle -n --options=.astylerc "${file}"; done
139+
- git diff --exit-code --diff-filter=d --color
153140

154141
STATUSM="Passed, ${CURR} files"
155142
if [ "$PREV" -ne 0 ]

0 commit comments

Comments
 (0)