From 5d2378dc1d9a48e56ba40098791cd0e4e322f9c5 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Tue, 16 Jul 2024 17:30:48 +0100 Subject: [PATCH] Handle merge conflict error Signed-off-by: Babak K. Shandiz --- pkg/cmd/pr/update/update.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cmd/pr/update/update.go b/pkg/cmd/pr/update/update.go index dda1fa3e8..6572a13b0 100644 --- a/pkg/cmd/pr/update/update.go +++ b/pkg/cmd/pr/update/update.go @@ -3,6 +3,7 @@ package update import ( "fmt" "net/http" + "strings" "github.com/MakeNowJust/heredoc" "github.com/cli/cli/v2/api" @@ -122,6 +123,11 @@ func updateRun(opts *UpdateOptions) error { err = updatePullRequestBranch(apiClient, repo, pr.ID, pr.HeadRefOid, opts.Rebase) opts.IO.StopProgressIndicator() if err != nil { + // TODO: this is a best effort approach and not a resilient way of handling API errors. + if strings.Contains(err.Error(), "GraphQL: merge conflict between base and head (updatePullRequestBranch)") { + fmt.Fprintf(opts.IO.ErrOut, "%s Cannot update PR branch due to conflicts\n", cs.FailureIcon()) + return cmdutil.SilentError + } return err }