Skip to content

Commit 3173faa

Browse files
authored
[🍒][ci] Fix the base branch we use to determine changes (#79503) (#79506)
We should diff against the base branch, not always against `main`. This allows the BuildKite pre-commit CI to work properly when we target other branches, such as `release/18.x`. (cherry picked from commit 3b76289)
1 parent 6abd792 commit 3173faa

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ set -o pipefail
2222

2323
# Environment variables script works with:
2424

25-
# Fetch origin/main to have an up to date merge base for main...HEAD diff.
26-
git fetch origin main:main
25+
# Set by buildkite
26+
: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH:=}
27+
: ${BUILDKITE_COMMIT:=}
28+
: ${BUILDKITE_BRANCH:=}
29+
# Fetch origin to have an up to date merge base for the diff.
30+
git fetch origin
2731
# List of files affected by this commit
28-
: ${MODIFIED_FILES:=$(git diff --name-only main...HEAD)}
32+
: ${MODIFIED_FILES:=$(git diff --name-only origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD)}
2933
# Filter rules for generic windows tests
3034
: ${WINDOWS_AGENTS:='{"queue": "windows"}'}
3135
# Filter rules for generic linux tests
3236
: ${LINUX_AGENTS:='{"queue": "linux"}'}
3337
# Service agents, for interacting with Phabricator.
3438
: ${SERVICE_AGENTS:='{"queue": "service"}'}
35-
# Set by buildkite
36-
: ${BUILDKITE_COMMIT:=}
37-
: ${BUILDKITE_BRANCH:=}
3839

3940
reviewID="$(git log --format=%B -n 1 | sed -nE 's/^Review-ID:[[:space:]]*(.+)$/\1/p')"
4041
if [[ "${reviewID}" != "" ]]; then

0 commit comments

Comments
 (0)