Skip to content

Commit

Permalink
Prevent nil pointer in GetPullRequestCommitStatusState (go-gitea#10342)
Browse files Browse the repository at this point in the history
Ensure that pr.HeadRepo is loaded before using it in GetPullRequestCommitStatusState.

Fixes error on merging with successful commit merge statuses.
  • Loading branch information
zeripath committed Feb 18, 2020
1 parent 457ee1a commit bc6ad0f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/pull/commit_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bc6ad0f

Please sign in to comment.