From c6b1031f4ddedec128651a8e177854102267e259 Mon Sep 17 00:00:00 2001 From: Shuya Ma <87669292+shuyama1@users.noreply.github.com> Date: Tue, 2 Jul 2024 12:18:23 -0700 Subject: [PATCH] only check if commit exists in sync branches in downstream builds (#11097) --- .ci/magician/cmd/generate_downstream.go | 33 +++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/.ci/magician/cmd/generate_downstream.go b/.ci/magician/cmd/generate_downstream.go index fd28cf0978db..64ef6857f538 100644 --- a/.ci/magician/cmd/generate_downstream.go +++ b/.ci/magician/cmd/generate_downstream.go @@ -97,23 +97,24 @@ func execGenerateDownstream(baseBranch, command, repo, version, ref string, gh G if baseBranch == "" { baseBranch = "main" } - - var syncBranchPrefix string - if repo == "terraform" { - if version == "beta" { - syncBranchPrefix = "tpgb-sync" - } else if version == "ga" { - syncBranchPrefix = "tpg-sync" + if command == "downstream" { + var syncBranchPrefix string + if repo == "terraform" { + if version == "beta" { + syncBranchPrefix = "tpgb-sync" + } else if version == "ga" { + syncBranchPrefix = "tpg-sync" + } + } else if repo == "terraform-google-conversion" { + syncBranchPrefix = "tgc-sync" + } else if repo == "tf-oics" { + syncBranchPrefix = "tf-oics-sync" + } + syncBranch := getSyncBranch(syncBranchPrefix, baseBranch) + if syncBranchHasCommit(ref, syncBranch, rnr) { + fmt.Printf("Sync branch %s already has commit %s, skipping generation\n", syncBranch, ref) + os.Exit(0) } - } else if repo == "terraform-google-conversion" { - syncBranchPrefix = "tgc-sync" - } else if repo == "tf-oics" { - syncBranchPrefix = "tf-oics-sync" - } - syncBranch := getSyncBranch(syncBranchPrefix, baseBranch) - if syncBranchHasCommit(ref, syncBranch, rnr) { - fmt.Printf("Sync branch %s already has commit %s, skipping generation\n", syncBranch, ref) - os.Exit(0) } mmLocalPath := filepath.Join(rnr.GetCWD(), "..", "..")