From 917e729b9f309ea8a9232eab66f8d933c6f553ba Mon Sep 17 00:00:00 2001 From: Tammo Ippen Date: Tue, 4 Aug 2015 15:37:50 +0200 Subject: [PATCH 1/2] Process PR with github api and push via git Also install jq as json processor for talking to github API --- .travis.yml | 3 +++ build.sh | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d98bf4b82c..bd460f3f6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,6 +66,9 @@ before_install: # used for building cppcheck-1.69 - sudo apt-get install -y libpcre3 libpcre3-dev + # process json output from github api + - sudo apt-get install -y jq + install: - cython --version - python --version diff --git a/build.sh b/build.sh index e15efbd666..5e34004cf4 100644 --- a/build.sh +++ b/build.sh @@ -123,8 +123,14 @@ cppcheck --version # go back to NEST sources cd .. -# Extracting changed files between two commits -file_names=`git diff --name-only $TRAVIS_COMMIT_RANGE` +# Extracting changed files in PR / push +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + file_names=`curl "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/files" | jq '.[] | .filename'` +else + # extract filenames via git => has some problems with history rewrites + # see https://github.com/travis-ci/travis-ci/issues/2668 + file_names=`(git diff --name-only $TRAVIS_COMMIT_RANGE || echo "") | tr '\n' ' '` +fi format_error_files="" for f in $file_names; do From 8b446a007206ac3098b987b8875c1037e31092d2 Mon Sep 17 00:00:00 2001 From: Tammo Ippen Date: Thu, 6 Aug 2015 15:41:34 +0200 Subject: [PATCH 2/2] Also remove line breaks and " from filenames --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 5e34004cf4..e9ad058caa 100644 --- a/build.sh +++ b/build.sh @@ -125,7 +125,7 @@ cd .. # Extracting changed files in PR / push if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - file_names=`curl "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/files" | jq '.[] | .filename'` + file_names=`curl "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/files" | jq '.[] | .filename' | tr '\n' ' ' | tr '"' ' '` else # extract filenames via git => has some problems with history rewrites # see https://github.com/travis-ci/travis-ci/issues/2668