aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/pull.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issues/pull.go')
-rw-r--r--models/issues/pull.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/models/issues/pull.go b/models/issues/pull.go
index efb24e8984..8c43eb19dd 100644
--- a/models/issues/pull.go
+++ b/models/issues/pull.go
@@ -499,65 +499,6 @@ func (pr *PullRequest) IsFromFork() bool {
return pr.HeadRepoID != pr.BaseRepoID
}
-// SetMerged sets a pull request to merged and closes the corresponding issue
-func (pr *PullRequest) SetMerged(ctx context.Context) (bool, error) {
- if pr.HasMerged {
- return false, fmt.Errorf("PullRequest[%d] already merged", pr.Index)
- }
- if pr.MergedCommitID == "" || pr.MergedUnix == 0 || pr.Merger == nil {
- return false, fmt.Errorf("Unable to merge PullRequest[%d], some required fields are empty", pr.Index)
- }
-
- pr.HasMerged = true
- sess := db.GetEngine(ctx)
-
- if _, err := sess.Exec("UPDATE `issue` SET `repo_id` = `repo_id` WHERE `id` = ?", pr.IssueID); err != nil {
- return false, err
- }
-
- if _, err := sess.Exec("UPDATE `pull_request` SET `issue_id` = `issue_id` WHERE `id` = ?", pr.ID); err != nil {
- return false, err
- }
-
- pr.Issue = nil
- if err := pr.LoadIssue(ctx); err != nil {
- return false, err
- }
-
- if tmpPr, err := GetPullRequestByID(ctx, pr.ID); err != nil {
- return false, err
- } else if tmpPr.HasMerged {
- if pr.Issue.IsClosed {
- return false, nil
- }
- return false, fmt.Errorf("PullRequest[%d] already merged but it's associated issue [%d] is not closed", pr.Index, pr.IssueID)
- } else if pr.Issue.IsClosed {
- return false, fmt.Errorf("PullRequest[%d] already closed", pr.Index)
- }
-
- if err := pr.Issue.LoadRepo(ctx); err != nil {
- return false, err
- }
-
- if err := pr.Issue.Repo.LoadOwner(ctx); err != nil {
- return false, err
- }
-
- if _, err := changeIssueStatus(ctx, pr.Issue, pr.Merger, true, true); err != nil {
- return false, fmt.Errorf("Issue.changeStatus: %w", err)
- }
-
- // reset the conflicted files as there cannot be any if we're merged
- pr.ConflictedFiles = []string{}
-
- // We need to save all of the data used to compute this merge as it may have already been changed by TestPatch. FIXME: need to set some state to prevent TestPatch from running whilst we are merging.
- if _, err := sess.Where("id = ?", pr.ID).Cols("has_merged, status, merge_base, merged_commit_id, merger_id, merged_unix, conflicted_files").Update(pr); err != nil {
- return false, fmt.Errorf("Failed to update pr[%d]: %w", pr.ID, err)
- }
-
- return true, nil
-}
-
// NewPullRequest creates new pull request with labels for repository.
func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *Issue, labelIDs []int64, uuids []string, pr *PullRequest) (err error) {
ctx, committer, err := db.TxContext(ctx)