Skip to content

Commit e90d88d

Browse files
yzzyxsapk
authored andcommitted
Backport of commit status fixes in PR #8316 and PR #8321 to v1.9 (#8339)
* 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]> * Fix pull request commit status in user dashboard list
1 parent 7156e2a commit e90d88d

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

models/pull.go

+6-3
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.GetBaseRepo()
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

+2-2
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

templates/user/dashboard/issues.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
<a class="title has-emoji" href="{{AppSubUrl}}/{{.Repo.Owner.Name}}/{{.Repo.Name}}/issues/{{.Index}}">{{.Title}}</a>
6969

7070
{{if .IsPull }}
71-
{{if (index $.CommitStatus .ID)}}
72-
{{template "repo/commit_status" (index $.CommitStatus .ID)}}
71+
{{if (index $.CommitStatus .PullRequest.ID)}}
72+
{{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}
7373
{{end}}
7474
{{end}}
7575

0 commit comments

Comments
 (0)