Skip to content

Commit

Permalink
Support CI for matching branches on forks
Browse files Browse the repository at this point in the history
Currently, people with push access to the main Riot repos can push matching
branch names to Riot and the SDKs, and CI will test all the branches together.
This change allows contributors to access the same ability when submitting
several matching PRs from their fork of each repo.

Part of #9041
  • Loading branch information
jryans committed Mar 19, 2019
1 parent 9735c33 commit 302691d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions scripts/fetch-develop.deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# the branch the current checkout is on, use that branch. Otherwise,
# use develop.

set -e
set -ex

GIT_CLONE_ARGS=("$@")
[ -z "$defbranch" ] && defbranch="develop"
Expand Down Expand Up @@ -41,7 +41,19 @@ function dodep() {
# Try the target branch of the push or PR.
# Use the default branch as the last resort.
if [[ "$BUILDKITE" == true ]]; then
clone $org $repo $BUILDKITE_BRANCH ||
# If BUILDKITE_BRANCH is set, it will contain either:
# * "branch" when the author's branch and target branch are in the same repo
# * "author:branch" when the author's branch is in their fork
# We can split on `:` into an array to check.
BUILDKITE_BRANCH_ARRAY=(${BUILDKITE_BRANCH//:/ })
if [[ "${#BUILDKITE_BRANCH_ARRAY[@]}" == "2" ]]; then
prAuthor=${BUILDKITE_BRANCH_ARRAY[0]}
prBranch=${BUILDKITE_BRANCH_ARRAY[1]}
else
prAuthor=$org
prBranch=$BUILDKITE_BRANCH
fi
clone $prAuthor $repo $prBranch ||
clone $org $repo $BUILDKITE_PULL_REQUEST_BASE_BRANCH ||
clone $org $repo $defbranch ||
return $?
Expand Down

0 comments on commit 302691d

Please sign in to comment.