From 2d3b471daffccaf18b25cc061bf46fb5a12024bd Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Tue, 7 Mar 2023 23:18:18 -0800 Subject: [PATCH] Restrict target branch existence check to public BuildKite pipeline. PiperOrigin-RevId: 514942919 --- .buildkite/hooks/pre-command | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 0a9ee356b..27b3b6df0 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -1,10 +1,12 @@ set -euo pipefail -# Check that the target branch exists. -git fetch origin "${BUILDKITE_BRANCH}" || { - echo "Branch ${BUILDKITE_BRANCH} no longer exists; it was probably deleted by the time we got to it." >&2 - exit 1 -} +if [[ "${BUILDKITE_PIPELINE_NAME:-}" == "Pipeline" ]]; then + # Check that the target branch exists. + git fetch origin "${BUILDKITE_BRANCH}" || { + echo "Branch ${BUILDKITE_BRANCH} no longer exists; it was probably deleted by the time we got to it." >&2 + exit 1 + } +fi # Download any build-specific configuration that has been uploaded. # This allows top-level steps to override all subsequent steps.