From ec3163779fd7a7eed5844345302be5198041aa14 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 10 Nov 2016 17:42:39 -0800 Subject: [PATCH] Fetch a connected sass-spec pull request. --- .travis.yml | 5 ++++- tool/sass-spec-ref.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 tool/sass-spec-ref.sh diff --git a/.travis.yml b/.travis.yml index a738c6bf5..a06441a19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,10 @@ install: - unzip dart.zip - export PATH="$PATH:`pwd`/dart-sdk/bin" - pub get -- git clone git://github.com/sass/sass-spec --branch dart-sass --depth 1 +- SASS_SPEC_REF=`tool/sass-spec-ref.sh` +- git init sass-spec +- git -C sass-spec fetch git://github.com/sass/sass-spec "$SASS_SPEC_REF" --depth 1 +- git -C sass-spec checkout FETCH_HEAD - (cd sass-spec; bundle install --jobs=3 --retry=3) script: diff --git a/tool/sass-spec-ref.sh b/tool/sass-spec-ref.sh new file mode 100755 index 000000000..c29ecfdcf --- /dev/null +++ b/tool/sass-spec-ref.sh @@ -0,0 +1,30 @@ +#!/bin/bash -e +# Copyright 2016 Google Inc. Use of this source code is governed by an MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT. + +# Echoes the sass-spec Git ref that should be checked out for the current Travis +# run. If we're running specs for a pull request which refers to a sass-spec +# pull request, we'll run against the latter rather than sass-spec master. + +default=dart-sass + +if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + >&2 echo "Ref: $default." + echo "$default" +fi + +>&2 echo "Fetching pull request $TRAVIS_PULL_REQUEST..." + +JSON=$(curl -L -sS https://api.github.com/repos/sass/dart-sass/pulls/$TRAVIS_PULL_REQUEST) + +RE_SPEC_PR="sass\/sass-spec(#|\/pull\/)([0-9]+)" + +if [[ $JSON =~ $RE_SPEC_PR ]]; then + ref="pull/${BASH_REMATCH[2]}/head" + >&2 echo "Ref: $ref." + echo "$ref" +else + >&2 echo "Ref: $default." + echo "$default" +fi