mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 01:48:30 +02:00
Support auto detecting branch for PRs (#525)
Fix #524 Co-authored-by: harryzcy <harry@harryzheng.com> Co-authored-by: techknowlogick <techknowlogick@gitea.com> Reviewed-on: https://gitea.com/gitea/tea/pulls/525 Co-authored-by: harryzcy <harryzcy@noreply.gitea.com> Co-committed-by: harryzcy <harryzcy@noreply.gitea.com>
This commit is contained in:
24
modules/task/pull_merge.go
Normal file
24
modules/task/pull_merge.go
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package task
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
)
|
||||
|
||||
// PullMerge merges a PR
|
||||
func PullMerge(login *config.Login, repoOwner, repoName string, index int64, opt gitea.MergePullRequestOption) error {
|
||||
client := login.Client()
|
||||
success, _, err := client.MergePullRequest(repoOwner, repoName, index, opt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !success {
|
||||
return fmt.Errorf("Failed to merge PR. Is it still open?")
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user