summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-02-18 19:34:08 +0000
committerGitHub <noreply@github.com>2020-02-18 19:34:08 +0000
commit13c6681a078e55c0e857eb101ab5138d211b1deb (patch)
tree38cf78f00a3a04b398b59c8436a6055ea86e6ba6 /services
parent29efa9c3fb47a00f03bf5d2fdcacd004dc790290 (diff)
downloadgitea-13c6681a078e55c0e857eb101ab5138d211b1deb.tar.gz
gitea-13c6681a078e55c0e857eb101ab5138d211b1deb.zip
Prevent nil pointer in GetPullRequestCommitStatusState (#10342)
Ensure that pr.HeadRepo is loaded before using it in GetPullRequestCommitStatusState. Fixes error on merging with successful commit merge statuses.
Diffstat (limited to 'services')
-rw-r--r--services/pull/commit_status.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/services/pull/commit_status.go b/services/pull/commit_status.go
index 77aca48556..a4803bfb9f 100644
--- a/services/pull/commit_status.go
+++ b/services/pull/commit_status.go
@@ -91,6 +91,11 @@ func IsPullCommitStatusPass(pr *models.PullRequest) (bool, error) {
// GetPullRequestCommitStatusState returns pull request merged commit status state
func GetPullRequestCommitStatusState(pr *models.PullRequest) (structs.CommitStatusState, error) {
+ // Ensure HeadRepo is loaded
+ if err := pr.LoadHeadRepo(); err != nil {
+ return "", errors.Wrap(err, "LoadHeadRepo")
+ }
+
// check if all required status checks are successful
headGitRepo, err := git.OpenRepository(pr.HeadRepo.RepoPath())
if err != nil {