Skip to content

Commit

Permalink
Avoids checking out the PR if BUILDKITE_PULL_REQUEST is 'false'
Browse files Browse the repository at this point in the history
  • Loading branch information
zsims committed Jun 8, 2018
1 parent 76f4b8c commit 189f0d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hooks/checkout
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail

if [[ -n "${BUILDKITE_PULL_REQUEST}" ]] ; then
if [[ -n "${BUILDKITE_PULL_REQUEST}" && "${BUILDKITE_PULL_REQUEST}" != "false" ]] ; then
echo "--- Checking out merge ref for PR ${BUILDKITE_PULL_REQUEST}"
git fetch origin "refs/pull/${BUILDKITE_PULL_REQUEST}/merge"
git checkout FETCH_HEAD
Expand Down
12 changes: 12 additions & 0 deletions tests/checkout.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ checkout_hook="$PWD/hooks/checkout"

run "$checkout_hook"

assert_success
refute_output --partial "GIT_FETCHED"
refute_output --partial "GIT_CHECKED_OUT_FETCH_HEAD"
assert_output --partial "No BUILDKITE_PULL_REQUEST variable set"
}

@test "Does nothing if no PR variable is false" {
export -f git
export BUILDKITE_PULL_REQUEST="false"

run "$checkout_hook"

assert_success
refute_output --partial "GIT_FETCHED"
refute_output --partial "GIT_CHECKED_OUT_FETCH_HEAD"
Expand Down

0 comments on commit 189f0d3

Please sign in to comment.