Skip to content

Commit defdc2f

Browse files
yzzyxdschmidt
authored andcommitted
Show correct commit status in PR list (go-gitea#8316)
* 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]>
1 parent c846006 commit defdc2f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

models/pull.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,17 @@ func (pr *PullRequest) GetLastCommitStatus() (status *CommitStatus, err error) {
339339
return nil, err
340340
}
341341

342-
repo := pr.HeadRepo
343342
lastCommitID, err := headGitRepo.GetBranchCommitID(pr.HeadBranch)
344343
if err != nil {
345344
return nil, err
346345
}
347346

348-
var statusList []*CommitStatus
349-
statusList, err = GetLatestCommitStatus(repo, lastCommitID, 0)
347+
err = pr.LoadBaseRepo()
348+
if err != nil {
349+
return nil, err
350+
}
351+
352+
statusList, err := GetLatestCommitStatus(pr.BaseRepo, lastCommitID, 0)
350353
if err != nil {
351354
return nil, err
352355
}

templates/repo/issue/list.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@
212212
<a class="title has-emoji" href="{{$.Link}}/{{.Index}}">{{.Title}}</a>
213213

214214
{{if .IsPull }}
215-
{{if (index $.CommitStatus .ID)}}
216-
{{template "repo/commit_status" (index $.CommitStatus .ID)}}
215+
{{if (index $.CommitStatus .PullRequest.ID)}}
216+
{{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}
217217
{{end}}
218218
{{end}}
219219

0 commit comments

Comments
 (0)