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) } }