From 63fe3778348945c1245b1f44c59d7614ed4e5739 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Thu, 21 Sep 2023 14:25:53 -0700 Subject: [PATCH] Unblock Feature branch by no merging main if BASE_BRANCH != main (#9040) --- .ci/gcb-community-checker.yml | 25 +++++++++++----------- .ci/gcb-contributor-membership-checker.yml | 25 +++++++++++----------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.ci/gcb-community-checker.yml b/.ci/gcb-community-checker.yml index b7032b5c6148..08712995646b 100644 --- a/.ci/gcb-community-checker.yml +++ b/.ci/gcb-community-checker.yml @@ -22,13 +22,6 @@ steps: - user.name - "Modular Magician Diff Process" - # Fetch main (only if it's not already present) - - name: "gcr.io/cloud-builders/git" - args: - - fetch - - origin - - main - # Display commit log for clarity - name: "gcr.io/cloud-builders/git" args: @@ -36,18 +29,24 @@ steps: - "--oneline" - "-n 10" - # Find common ancestor commit and apply diff for the .ci folder + # Find common ancestor commit and apply diff for the .ci folder. - name: "gcr.io/cloud-builders/git" id: findMergeBase entrypoint: "bash" args: - "-c" - | - base_commit=$(git merge-base origin/main HEAD) - echo "Common ancestor commit: $base_commit" - git diff $base_commit origin/main -- .ci/ - git diff $base_commit origin/main -- .ci/ > /workspace/ci.diff - git apply /workspace/ci.diff --allow-empty + git fetch origin main + if [ "$_BASE_BRANCH" != "main" ]; then + echo "Checking out .ci/ folder from main" + git checkout origin/main -- .ci/ + else + base_commit=$(git merge-base origin/main HEAD) + echo "Common ancestor commit: $base_commit" + git diff $base_commit upstream/main -- .ci/ + git diff $base_commit upstream/main -- .ci/ > /workspace/ci.diff + git apply ./ci.diff --allow-empty + fi - name: 'gcr.io/graphite-docker-images/go-plus' entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh' diff --git a/.ci/gcb-contributor-membership-checker.yml b/.ci/gcb-contributor-membership-checker.yml index d44ea5a4b4a2..3164a75a5cf8 100644 --- a/.ci/gcb-contributor-membership-checker.yml +++ b/.ci/gcb-contributor-membership-checker.yml @@ -22,13 +22,6 @@ steps: - user.name - "Modular Magician Diff Process" - # Fetch main (only if it's not already present) - - name: "gcr.io/cloud-builders/git" - args: - - fetch - - origin - - main - # Display commit log for clarity - name: "gcr.io/cloud-builders/git" args: @@ -36,18 +29,24 @@ steps: - "--oneline" - "-n 10" - # Find common ancestor commit and apply diff for the .ci folder + # Find common ancestor commit and apply diff for the .ci folder. - name: "gcr.io/cloud-builders/git" id: findMergeBase entrypoint: "bash" args: - "-c" - | - base_commit=$(git merge-base origin/main HEAD) - echo "Common ancestor commit: $base_commit" - git diff $base_commit origin/main -- .ci/ - git diff $base_commit origin/main -- .ci/ > /workspace/ci.diff - git apply /workspace/ci.diff --allow-empty + git fetch origin main + if [ "$_BASE_BRANCH" != "main" ]; then + echo "Checking out .ci/ folder from main" + git checkout origin/main -- .ci/ + else + base_commit=$(git merge-base origin/main HEAD) + echo "Common ancestor commit: $base_commit" + git diff $base_commit upstream/main -- .ci/ + git diff $base_commit upstream/main -- .ci/ > /workspace/ci.diff + git apply ./ci.diff --allow-empty + fi - name: "gcr.io/graphite-docker-images/go-plus" entrypoint: "/workspace/.ci/scripts/go-plus/magician/exec.sh"