Skip to content

Commit 973b2cc

Browse files
committed
log http 409 merge conflicts under debug as it will show up in the PR body anyways
1 parent 63dbbc4 commit 973b2cc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

internal/cmd/combine_prs.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"io"
9+
"strings"
910

1011
"github.com/cli/go-gh/v2/pkg/api"
1112
)
@@ -61,7 +62,14 @@ func CombinePRs(ctx context.Context, graphQlClient *api.GraphQLClient, restClien
6162
for _, pr := range matchedPRs {
6263
err := mergeBranch(ctx, restClient, owner, repo, workingBranchName, pr.Branch)
6364
if err != nil {
64-
Logger.Warn("Failed to merge branch", "branch", pr.Branch, "error", err)
65+
// Check if the error is a 409 merge conflict
66+
if isMergeConflictError(err) {
67+
// Log merge conflicts at DEBUG level
68+
Logger.Debug("Merge conflict", "branch", pr.Branch, "error", err)
69+
} else {
70+
// Log other errors at WARN level
71+
Logger.Warn("Failed to merge branch", "branch", pr.Branch, "error", err)
72+
}
6573
mergeFailedPRs = append(mergeFailedPRs, fmt.Sprintf("#%d", pr.Number))
6674
} else {
6775
Logger.Debug("Merged branch", "branch", pr.Branch)
@@ -92,6 +100,12 @@ func CombinePRs(ctx context.Context, graphQlClient *api.GraphQLClient, restClien
92100
return nil
93101
}
94102

103+
// isMergeConflictError checks if the error is a 409 Merge Conflict
104+
func isMergeConflictError(err error) bool {
105+
// Check if the error message contains "HTTP 409: Merge conflict"
106+
return err != nil && strings.Contains(err.Error(), "HTTP 409: Merge conflict")
107+
}
108+
95109
// Find the default branch of a repository
96110
func getDefaultBranch(ctx context.Context, client *api.RESTClient, owner, repo string) (string, error) {
97111
var repoInfo struct {

0 commit comments

Comments
 (0)