summaryrefslogtreecommitdiffstats
path: root/models/pull_list.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/pull_list.go')
-rw-r--r--models/pull_list.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/models/pull_list.go b/models/pull_list.go
index 8fa80307de..ed8372658d 100644
--- a/models/pull_list.go
+++ b/models/pull_list.go
@@ -7,6 +7,7 @@ package models
import (
"fmt"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
@@ -24,7 +25,7 @@ type PullRequestsOptions struct {
}
func listPullRequestStatement(baseRepoID int64, opts *PullRequestsOptions) (*xorm.Session, error) {
- sess := x.Where("pull_request.base_repo_id=?", baseRepoID)
+ sess := db.DefaultContext().Engine().Where("pull_request.base_repo_id=?", baseRepoID)
sess.Join("INNER", "issue", "pull_request.issue_id = issue.id")
switch opts.State {
@@ -50,7 +51,7 @@ func listPullRequestStatement(baseRepoID int64, opts *PullRequestsOptions) (*xor
// by given head information (repo and branch).
func GetUnmergedPullRequestsByHeadInfo(repoID int64, branch string) ([]*PullRequest, error) {
prs := make([]*PullRequest, 0, 2)
- return prs, x.
+ return prs, db.DefaultContext().Engine().
Where("head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?",
repoID, branch, false, false, PullRequestFlowGithub).
Join("INNER", "issue", "issue.id = pull_request.issue_id").
@@ -61,7 +62,7 @@ func GetUnmergedPullRequestsByHeadInfo(repoID int64, branch string) ([]*PullRequ
// by given base information (repo and branch).
func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequest, error) {
prs := make([]*PullRequest, 0, 2)
- return prs, x.
+ return prs, db.DefaultContext().Engine().
Where("base_repo_id=? AND base_branch=? AND has_merged=? AND issue.is_closed=?",
repoID, branch, false, false).
Join("INNER", "issue", "issue.id=pull_request.issue_id").
@@ -71,7 +72,7 @@ func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequ
// GetPullRequestIDsByCheckStatus returns all pull requests according the special checking status.
func GetPullRequestIDsByCheckStatus(status PullRequestStatus) ([]int64, error) {
prs := make([]int64, 0, 10)
- return prs, x.Table("pull_request").
+ return prs, db.DefaultContext().Engine().Table("pull_request").
Where("status=?", status).
Cols("pull_request.id").
Find(&prs)
@@ -108,7 +109,7 @@ func PullRequests(baseRepoID int64, opts *PullRequestsOptions) ([]*PullRequest,
// PullRequestList defines a list of pull requests
type PullRequestList []*PullRequest
-func (prs PullRequestList) loadAttributes(e Engine) error {
+func (prs PullRequestList) loadAttributes(e db.Engine) error {
if len(prs) == 0 {
return nil
}
@@ -143,10 +144,10 @@ func (prs PullRequestList) getIssueIDs() []int64 {
// LoadAttributes load all the prs attributes
func (prs PullRequestList) LoadAttributes() error {
- return prs.loadAttributes(x)
+ return prs.loadAttributes(db.DefaultContext().Engine())
}
-func (prs PullRequestList) invalidateCodeComments(e Engine, doer *User, repo *git.Repository, branch string) error {
+func (prs PullRequestList) invalidateCodeComments(e db.Engine, doer *User, repo *git.Repository, branch string) error {
if len(prs) == 0 {
return nil
}
@@ -168,5 +169,5 @@ func (prs PullRequestList) invalidateCodeComments(e Engine, doer *User, repo *gi
// InvalidateCodeComments will lookup the prs for code comments which got invalidated by change
func (prs PullRequestList) InvalidateCodeComments(doer *User, repo *git.Repository, branch string) error {
- return prs.invalidateCodeComments(x, doer, repo, branch)
+ return prs.invalidateCodeComments(db.DefaultContext().Engine(), doer, repo, branch)
}