Skip to content

Commit 13c6681

Browse files
authored
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.
1 parent 29efa9c commit 13c6681

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

services/pull/commit_status.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ func IsPullCommitStatusPass(pr *models.PullRequest) (bool, error) {
9191

9292
// GetPullRequestCommitStatusState returns pull request merged commit status state
9393
func GetPullRequestCommitStatusState(pr *models.PullRequest) (structs.CommitStatusState, error) {
94+
// Ensure HeadRepo is loaded
95+
if err := pr.LoadHeadRepo(); err != nil {
96+
return "", errors.Wrap(err, "LoadHeadRepo")
97+
}
98+
9499
// check if all required status checks are successful
95100
headGitRepo, err := git.OpenRepository(pr.HeadRepo.RepoPath())
96101
if err != nil {

0 commit comments

Comments
 (0)