From 2a49ddee23507444028d66df0dd95019581dd04d Mon Sep 17 00:00:00 2001 From: michaelschiff Date: Tue, 3 Oct 2023 22:04:50 -0700 Subject: [PATCH 1/3] Changes to prer to allow setting prTitle and prBody did not correctly preserve prior behavior for users who do not set these new arguments --- gitops/prer/create_gitops_prs.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gitops/prer/create_gitops_prs.go b/gitops/prer/create_gitops_prs.go index 2ed30ef4..146358d0 100644 --- a/gitops/prer/create_gitops_prs.go +++ b/gitops/prer/create_gitops_prs.go @@ -54,7 +54,7 @@ var ( releaseBranch = flag.String("release_branch", "master", "filter gitops targets by release branch") bazelCmd = flag.String("bazel_cmd", "tools/bazel", "bazel binary to use") workspace = flag.String("workspace", "", "path to workspace root") - repo = flag.String("git_repo", "https://bitbucket.tubemogul.info/scm/tm/repo.git", "git repo location") + repo = flag.String("git_repo", "", "git repo location") gitMirror = flag.String("git_mirror", "", "git mirror location, like /mnt/mirror/bitbucket.tubemogul.info/tm/repo.git for jenkins") gitopsPath = flag.String("gitops_path", "cloud", "location to store files in repo.") gitopsTmpDir = flag.String("gitops_tmpdir", os.TempDir(), "location to check out git tree with /cloud.") @@ -62,7 +62,7 @@ var ( pushParallelism = flag.Int("push_parallelism", 5, "Number of image pushes to perform concurrently") prInto = flag.String("gitops_pr_into", "master", "use this branch as the source branch and target for deployment PR") prBody = flag.String("gitops_pr_body", "GitOps deployment ", "a body message for deployment PR") - prTitle = flag.String("gitops_pr_title", "GitOps deployment ", "a title for deployment PR") + prTitle = flag.String("gitops_pr_title", "", "a title for deployment PR") branchName = flag.String("branch_name", "unknown", "Branch name to use in commit message") gitCommit = flag.String("git_commit", "unknown", "Git commit to use in commit message") deploymentBranchSuffix = flag.String("deployment_branch_suffix", "", "suffix to add to all deployment branch names") @@ -252,11 +252,17 @@ func main() { continue } - if *prTitle == "" { - *prTitle = fmt.Sprintf("GitOps deployment %s", branch) + title := *prTitle + if title == "" { + title = fmt.Sprintf("GitOps deployment %s", branch) } - err := gitServer.CreatePR(branch, *prInto, *prTitle, *prBody) + body := *prBody + if body == "" { + body = branch + } + + err := gitServer.CreatePR(branch, *prInto, title, body) if err != nil { log.Fatal("unable to create PR: ", err) } From be97ef4996614bf2741a6086ecbd6c7f7f8e8c64 Mon Sep 17 00:00:00 2001 From: michaelschiff Date: Tue, 3 Oct 2023 22:09:11 -0700 Subject: [PATCH 2/3] remove default --- gitops/prer/create_gitops_prs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitops/prer/create_gitops_prs.go b/gitops/prer/create_gitops_prs.go index 146358d0..0306b686 100644 --- a/gitops/prer/create_gitops_prs.go +++ b/gitops/prer/create_gitops_prs.go @@ -61,7 +61,7 @@ var ( target = flag.String("target", "//... except //experimental/...", "target to scan. Useful for debugging only") pushParallelism = flag.Int("push_parallelism", 5, "Number of image pushes to perform concurrently") prInto = flag.String("gitops_pr_into", "master", "use this branch as the source branch and target for deployment PR") - prBody = flag.String("gitops_pr_body", "GitOps deployment ", "a body message for deployment PR") + prBody = flag.String("gitops_pr_body", "", "a body message for deployment PR") prTitle = flag.String("gitops_pr_title", "", "a title for deployment PR") branchName = flag.String("branch_name", "unknown", "Branch name to use in commit message") gitCommit = flag.String("git_commit", "unknown", "Git commit to use in commit message") From f08992632af0d68386ee7cda5e58e564baa74087 Mon Sep 17 00:00:00 2001 From: michaelschiff Date: Tue, 3 Oct 2023 22:11:10 -0700 Subject: [PATCH 3/3] condensed if syntax --- gitops/prer/create_gitops_prs.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gitops/prer/create_gitops_prs.go b/gitops/prer/create_gitops_prs.go index 0306b686..512d409e 100644 --- a/gitops/prer/create_gitops_prs.go +++ b/gitops/prer/create_gitops_prs.go @@ -262,8 +262,7 @@ func main() { body = branch } - err := gitServer.CreatePR(branch, *prInto, title, body) - if err != nil { + if err := gitServer.CreatePR(branch, *prInto, title, body); err != nil { log.Fatal("unable to create PR: ", err) } }