Skip to content

Commit

Permalink
Show correct commit status in PR list (go-gitea#8316)
Browse files Browse the repository at this point in the history
* Use correct index when fetching commit status

Signed-off-by: Elias Norberg <[email protected]>

* Compare against base repo to avoid mismatch when merging from fork

Signed-off-by: Elias Norberg <[email protected]>
  • Loading branch information
yzzyx authored and dschmidt committed Oct 1, 2019
1 parent c846006 commit defdc2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,17 @@ func (pr *PullRequest) GetLastCommitStatus() (status *CommitStatus, err error) {
return nil, err
}

repo := pr.HeadRepo
lastCommitID, err := headGitRepo.GetBranchCommitID(pr.HeadBranch)
if err != nil {
return nil, err
}

var statusList []*CommitStatus
statusList, err = GetLatestCommitStatus(repo, lastCommitID, 0)
err = pr.LoadBaseRepo()
if err != nil {
return nil, err
}

statusList, err := GetLatestCommitStatus(pr.BaseRepo, lastCommitID, 0)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@
<a class="title has-emoji" href="{{$.Link}}/{{.Index}}">{{.Title}}</a>

{{if .IsPull }}
{{if (index $.CommitStatus .ID)}}
{{template "repo/commit_status" (index $.CommitStatus .ID)}}
{{if (index $.CommitStatus .PullRequest.ID)}}
{{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}
{{end}}
{{end}}

Expand Down

0 comments on commit defdc2f

Please sign in to comment.