From e8a218f08f8e88b5c738333a44e1feb2ccbb3dd3 Mon Sep 17 00:00:00 2001 From: jaskaransarkaria Date: Tue, 1 Oct 2024 11:40:15 +0100 Subject: [PATCH] =?UTF-8?q?fixup!=20fixup!=20feat:=20=F0=9F=8E=B8=20skip?= =?UTF-8?q?=20creating=20a=20pr=20for=20rds=20drift=20if=20one=20already?= =?UTF-8?q?=20exists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/environment/createPR.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/environment/createPR.go b/pkg/environment/createPR.go index 1b3411a2..ec2ed534 100644 --- a/pkg/environment/createPR.go +++ b/pkg/environment/createPR.go @@ -29,6 +29,15 @@ func createPR(description, namespace, ghToken, repo string) func(github.GithubIf useGhTokenCmd.Start() //nolint:errcheck useGhTokenCmd.Wait() //nolint:errcheck + pulls, err := gh.ListOpenPRs(namespace) + if err != nil { + fmt.Printf("warning: Error listing open prs: %v\n", err) + } + + if len(pulls) > 0 { + return "", errors.New("a pr is already open for this namespace, skipping opening another") + } + checkCmd := exec.Command("/bin/sh", "-c", "git checkout -b "+branchName) checkCmd.Start() //nolint:errcheck checkCmd.Wait() //nolint:errcheck @@ -48,15 +57,6 @@ func createPR(description, namespace, ghToken, repo string) func(github.GithubIf pushCmd.Start() //nolint:errcheck pushCmd.Wait() //nolint:errcheck - pulls, err := gh.ListOpenPRs(namespace) - if err != nil { - fmt.Printf("warning: Error listing open prs: %v\n", err) - } - - if len(pulls) > 0 { - return "", errors.New("a pr is already open for this namespace, skipping opening another") - } - return gh.CreatePR(branchName, namespace, description) } }