From 7d8b1b808a2659677902abc8c4a1997cfea73e90 Mon Sep 17 00:00:00 2001 From: Doug Weyrauch Date: Fri, 17 Jan 2025 14:47:35 -0500 Subject: [PATCH 1/2] Try to use forked branch --- .buildkite/hooks/post-checkout | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.buildkite/hooks/post-checkout b/.buildkite/hooks/post-checkout index e10f15de7b6..d1c17595e72 100755 --- a/.buildkite/hooks/post-checkout +++ b/.buildkite/hooks/post-checkout @@ -51,3 +51,16 @@ git --no-pager log --format=%B -n 1 # Ensure buildkite groups are rendered echo "" + +USE_FORKED_REPO="${FORKED_REPO:-}" +USE_FORKED_BRANCH="${FORKED_BRANCH:-}" + +if [ -n "${USE_FORKED_REPO}" ]; then + if [ -n "${USE_FORKED_BRANCH}" ]; then + # checkout + echo "Checking out branch ${USE_FORKED_BRANCH} from github repo ${USE_FORKED_REPO}" + git remote add forked "git@github.com:${USE_FORKED_REPO}" + git fetch forked + git checkout "${USE_FORKED_BRANCH}" + fi +fi From 64fb2174acf54b9dbbd364889cabf474512933d3 Mon Sep 17 00:00:00 2001 From: Doug Weyrauch Date: Fri, 17 Jan 2025 15:05:16 -0500 Subject: [PATCH 2/2] Fix logic --- .buildkite/hooks/post-checkout | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/.buildkite/hooks/post-checkout b/.buildkite/hooks/post-checkout index d1c17595e72..e341582493e 100755 --- a/.buildkite/hooks/post-checkout +++ b/.buildkite/hooks/post-checkout @@ -36,6 +36,25 @@ pull_request="${BUILDKITE_PULL_REQUEST:-false}" if [[ "${pull_request}" == "false" ]]; then echo "Not a pull request, skipping" + + USE_FORKED_REPO="${FORKED_REPO:-}" + USE_FORKED_BRANCH="${FORKED_BRANCH:-}" + + echo "Forked repo: ${USE_FORKED_REPO}" + echo "Forked branch: ${USE_FORKED_BRANCH}" + if [ -n "${USE_FORKED_REPO}" ]; then + echo "Insided forked repo if" + if [ -n "${USE_FORKED_BRANCH}" ]; then + echo "Inside forked branch if" + # checkout + echo "Checking out branch ${USE_FORKED_BRANCH} from github repo ${USE_FORKED_REPO}" + git remote add forked "git@github.com:${USE_FORKED_REPO}" + git fetch forked + git checkout "${USE_FORKED_BRANCH}" + fi + fi + echo "After forked repo/branch statements" + exit 0 fi @@ -51,16 +70,3 @@ git --no-pager log --format=%B -n 1 # Ensure buildkite groups are rendered echo "" - -USE_FORKED_REPO="${FORKED_REPO:-}" -USE_FORKED_BRANCH="${FORKED_BRANCH:-}" - -if [ -n "${USE_FORKED_REPO}" ]; then - if [ -n "${USE_FORKED_BRANCH}" ]; then - # checkout - echo "Checking out branch ${USE_FORKED_BRANCH} from github repo ${USE_FORKED_REPO}" - git remote add forked "git@github.com:${USE_FORKED_REPO}" - git fetch forked - git checkout "${USE_FORKED_BRANCH}" - fi -fi