mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-05 18:58:43 +02:00
28ba9b915b
Reviewed-on: https://gitea.com/gitea/tea/pulls/1006 Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
27 lines
624 B
Go
27 lines
624 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package task
|
|
|
|
import (
|
|
stdctx "context"
|
|
"fmt"
|
|
|
|
gitea "gitea.dev/sdk"
|
|
|
|
"gitea.dev/tea/modules/config"
|
|
)
|
|
|
|
// PullMerge merges a PR
|
|
func PullMerge(requestCtx stdctx.Context, login *config.Login, repoOwner, repoName string, index int64, opt gitea.MergePullRequestOption) error {
|
|
client := login.Client()
|
|
success, _, err := client.PullRequests.MergePullRequest(requestCtx, repoOwner, repoName, index, opt)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !success {
|
|
return fmt.Errorf("failed to merge PR, is it still open?")
|
|
}
|
|
return nil
|
|
}
|