Skip to content

Commit

Permalink
feat: support other merge methods
Browse files Browse the repository at this point in the history
  • Loading branch information
olegsu committed May 28, 2022
1 parent d71337c commit 34b9175
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/http/handlers/github_webook.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,12 @@ func processComment(ctx context.Context, lgr *logger.Logger, body GithubWebhookB
errs = append(errs, err)
}
case "merge":
lgr.Info("merging")
if err := onMerge(ctx, gh, body, prbot); err != nil {
method := "squash"
if len(tokens) >= 3 {
method = tokens[2]
}
lgr.Info("merging", "method", method)
if err := onMerge(ctx, gh, body, prbot, method); err != nil {
errs = append(errs, err)
}
case "workflow":
Expand Down Expand Up @@ -223,10 +227,10 @@ func onLabel(ctx context.Context, lgr *logger.Logger, gh GithubClient, body Gith
return err
}

func onMerge(ctx context.Context, gh GithubClient, body GithubWebhookBody, prbot PrBotFile) error {
func onMerge(ctx context.Context, gh GithubClient, body GithubWebhookBody, prbot PrBotFile, method string) error {
message := body.Issue.Title
_, _, err := gh.MergePullRequest(ctx, body.Repository.Owner.Login, body.Repository.Name, int(body.Issue.Number), message, &github.PullRequestOptions{
MergeMethod: "squash",
MergeMethod: method,
})
return err
}
Expand Down

0 comments on commit 34b9175

Please sign in to comment.