diff --git a/semaphoreci.sh b/semaphoreci.sh index 50c94948148d..a209005f86eb 100755 --- a/semaphoreci.sh +++ b/semaphoreci.sh @@ -19,8 +19,7 @@ export OS_NAME=linux export FULL_BUILD="${PULL_REQUEST_NUMBER+false}" # SemaphoreCI doesn't provide a convenient way to the base branch (e.g. master or stable) if [ -n "${PULL_REQUEST_NUMBER:-}" ]; then - # detect master/stable without querying the rate-limited API - BRANCH="$(git describe --all | sed -E "s/.*\/([^-/]*)-.*/\1/")" + BRANCH=$((curl -fsSL https://api.github.com/repos/dlang/dmd/pulls/$PULL_REQUEST_NUMBER || echo) | jq -r '.base.ref') # check if the detected branch actually exists and fallback to master if ! git ls-remote --exit-code --heads https://github.com/dlang/dmd.git "$BRANCH" > /dev/null ; then echo "Invalid branch detected: ${BRANCH} - falling back to master"