|
6 | 6 | "encoding/json"
|
7 | 7 | "fmt"
|
8 | 8 | "io"
|
| 9 | + "strings" |
9 | 10 |
|
10 | 11 | "github.com/cli/go-gh/v2/pkg/api"
|
11 | 12 | )
|
@@ -61,7 +62,14 @@ func CombinePRs(ctx context.Context, graphQlClient *api.GraphQLClient, restClien
|
61 | 62 | for _, pr := range matchedPRs {
|
62 | 63 | err := mergeBranch(ctx, restClient, owner, repo, workingBranchName, pr.Branch)
|
63 | 64 | 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 | + } |
65 | 73 | mergeFailedPRs = append(mergeFailedPRs, fmt.Sprintf("#%d", pr.Number))
|
66 | 74 | } else {
|
67 | 75 | Logger.Debug("Merged branch", "branch", pr.Branch)
|
@@ -92,6 +100,12 @@ func CombinePRs(ctx context.Context, graphQlClient *api.GraphQLClient, restClien
|
92 | 100 | return nil
|
93 | 101 | }
|
94 | 102 |
|
| 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 | + |
95 | 109 | // Find the default branch of a repository
|
96 | 110 | func getDefaultBranch(ctx context.Context, client *api.RESTClient, owner, repo string) (string, error) {
|
97 | 111 | var repoInfo struct {
|
|
0 commit comments