Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit ded8e1b

Browse files
author
Noah Lee
authored
feat: Handle merge conflicts and commit status check failures in CreateRemoteDeployment (#529)
This commit modifies the CreateRemoteDeployment function in the `deployment.go` file. It adds logic to handle merge conflicts and commit status check failures when creating a remote deployment. If a merge conflict is detected, the function returns an error message instructing the user to resolve the conflict before retrying. If a commit status check fails, the function returns an error message indicating that a commit status check has failed. Refactor the commit message to adhere to the established conventions.
1 parent ae0cc27 commit ded8e1b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

internal/pkg/github/deployment.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,21 @@ func (g *Github) CreateRemoteDeployment(ctx context.Context, u *ent.User, r *ent
3232
ProductionEnvironment: env.ProductionEnvironment,
3333
})
3434
if res.StatusCode == http.StatusConflict {
35+
// Determine if there is a merge conflict or a commit status check failed.
36+
// https://github.com/gitploy-io/gitploy/issues/526
37+
for _, es := range err.(*github.ErrorResponse).Errors {
38+
if es.Field == "required_contexts" {
39+
return nil, e.NewErrorWithMessage(
40+
e.ErrorCodeEntityUnprocessable,
41+
"A commit status check failed.",
42+
err,
43+
)
44+
}
45+
}
46+
3547
return nil, e.NewErrorWithMessage(
3648
e.ErrorCodeEntityUnprocessable,
37-
"There is merge conflict or a commit status check failed.",
49+
"There is merge conflict. Retry after resolving the conflict.",
3850
err,
3951
)
4052
} else if res.StatusCode == http.StatusUnprocessableEntity {

0 commit comments

Comments
 (0)