From d68a7f64b1f2660c0fd20456ce8078113e38e265 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Thu, 25 Jul 2019 14:29:32 +0100 Subject: [PATCH 1/2] Fix panic in #7611 Use pr.IssueID instead of pr.Issue.ID as Issue may not be loaded and is unnecessary --- models/branches.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/branches.go b/models/branches.go index c09e72e988fdc..3d3cff84d3330 100644 --- a/models/branches.go +++ b/models/branches.go @@ -101,7 +101,7 @@ func (protectBranch *ProtectedBranch) HasEnoughApprovals(pr *PullRequest) bool { // GetGrantedApprovalsCount returns the number of granted approvals for pr. A granted approval must be authored by a user in an approval whitelist. func (protectBranch *ProtectedBranch) GetGrantedApprovalsCount(pr *PullRequest) int64 { - reviews, err := GetReviewersByPullID(pr.Issue.ID) + reviews, err := GetReviewersByPullID(pr.IssueID) if err != nil { log.Error("GetReviewersByPullID: %v", err) return 0 From 032e34388e7daa3b509d5450cf072fc7f799dcbc Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Thu, 25 Jul 2019 14:50:39 +0100 Subject: [PATCH 2/2] Only fetch the head branch from the remote --- modules/pull/merge.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/pull/merge.go b/modules/pull/merge.go index 3b653aac2daaf..3e5721ad72f1c 100644 --- a/modules/pull/merge.go +++ b/modules/pull/merge.go @@ -101,7 +101,7 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor } // Fetch head branch - if err := git.NewCommand("fetch", remoteRepoName).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil { + if err := git.NewCommand("fetch", remoteRepoName, pr.HeadBranch).RunInDirPipeline(tmpBasePath, nil, &errbuf); err != nil { return fmt.Errorf("git fetch [%s -> %s]: %s", headRepoPath, tmpBasePath, errbuf.String()) }