2016-11-11 02:42:39 +01:00
|
|
|
#!/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.
|
|
|
|
|
2020-09-17 02:53:36 +02:00
|
|
|
if [[ "$TRAVIS_BRANCH" == feature.* ]]; then
|
|
|
|
default="$TRAVIS_BRANCH"
|
|
|
|
else
|
|
|
|
default=master
|
|
|
|
fi
|
2016-11-11 02:42:39 +01:00
|
|
|
|
|
|
|
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
2016-11-12 02:15:06 +01:00
|
|
|
>&2 echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST."
|
2016-11-11 02:42:39 +01:00
|
|
|
>&2 echo "Ref: $default."
|
|
|
|
echo "$default"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
>&2 echo "Fetching pull request $TRAVIS_PULL_REQUEST..."
|
|
|
|
|
2018-06-22 02:59:01 +02:00
|
|
|
url=https://api.github.com/repos/sass/dart-sass/pulls/$TRAVIS_PULL_REQUEST
|
2020-01-24 22:05:04 +01:00
|
|
|
if [ -z "$GITHUB_TOKEN" ]; then
|
2018-06-22 02:59:01 +02:00
|
|
|
>&2 echo "Fetching pull request info without authentication"
|
|
|
|
JSON=$(curl -L -sS $url)
|
|
|
|
else
|
|
|
|
>&2 echo "Fetching pull request info as sassbot"
|
2020-01-24 22:05:04 +01:00
|
|
|
JSON=$(curl -u "sassbot:$GITHUB_TOKEN" -L -sS $url)
|
2018-06-22 02:59:01 +02:00
|
|
|
fi
|
|
|
|
>&2 echo "$JSON"
|
2016-11-11 02:42:39 +01:00
|
|
|
|
|
|
|
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
|