From cac261aff43b7093a144e17db598a0e3737f5c7b Mon Sep 17 00:00:00 2001 From: Shray Kumar Date: Mon, 30 Jun 2025 11:59:25 -0400 Subject: [PATCH] add more verbosity to error --- gitops/git/github_app/github_app.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitops/git/github_app/github_app.go b/gitops/git/github_app/github_app.go index fdb59bef..f8397609 100644 --- a/gitops/git/github_app/github_app.go +++ b/gitops/git/github_app/github_app.go @@ -220,8 +220,11 @@ func getRef(ctx context.Context, gh *github.Client, baseBranch string, commitBra log.Printf("Creating ref for branch %s\n", commitBranch) newRef := &github.Reference{Ref: github.String("refs/heads/" + commitBranch), Object: &github.GitObject{SHA: baseRef.Object.SHA}} - ref, _, err := gh.Git.CreateRef(ctx, *repoOwner, *repo, newRef) + ref, resp, err := gh.Git.CreateRef(ctx, *repoOwner, *repo, newRef) if err != nil { + if resp != nil && resp.StatusCode == http.StatusUnprocessableEntity { + log.Printf("Branch reference '%s' already exists. Update your rules gitops pipeline to make your branch name more unique", commitBranch) + } log.Fatalf("failed to create branch ref: %v", err) } return ref