summaryrefslogtreecommitdiffstats
path: root/models/pull.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-02-27 08:42:55 +0800
committerGitHub <noreply@github.com>2017-02-27 08:42:55 +0800
commitd4e38cf129e30327039d08fa460017ace7959a84 (patch)
tree93791dcbcfe4e3f5ecaa52b773634a1a95698193 /models/pull.go
parent522f1949830fcf410b61497ee55162e676e1bdb6 (diff)
downloadgitea-d4e38cf129e30327039d08fa460017ace7959a84.tar.gz
gitea-d4e38cf129e30327039d08fa460017ace7959a84.zip
fix setMerged for remove unnecessary db connection (#1067)
Diffstat (limited to 'models/pull.go')
-rw-r--r--models/pull.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/models/pull.go b/models/pull.go
index 3e963400a4..29730ba7e0 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -115,11 +115,15 @@ func (pr *PullRequest) LoadAttributes() error {
// LoadIssue loads issue information from database
func (pr *PullRequest) LoadIssue() (err error) {
+ return pr.loadIssue(x)
+}
+
+func (pr *PullRequest) loadIssue(e Engine) (err error) {
if pr.Issue != nil {
return nil
}
- pr.Issue, err = GetIssueByID(pr.IssueID)
+ pr.Issue, err = getIssueByID(e, pr.IssueID)
return err
}
@@ -405,14 +409,15 @@ func (pr *PullRequest) setMerged() (err error) {
return err
}
- if err = pr.LoadIssue(); err != nil {
+ if err = pr.loadIssue(sess); err != nil {
return err
}
- if pr.Issue.Repo.Owner == nil {
- if err = pr.Issue.Repo.GetOwner(); err != nil {
- return err
- }
+ if err = pr.Issue.loadRepo(sess); err != nil {
+ return err
+ }
+ if err = pr.Issue.Repo.getOwner(sess); err != nil {
+ return err
}
if err = pr.Issue.changeStatus(sess, pr.Merger, pr.Issue.Repo, true); err != nil {