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 <elias@aisle.se>

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

Signed-off-by: Elias Norberg <elias@aisle.se>

* Fix pull request commit status in user dashboard list
This commit is contained in:
Elias Norberg 2019-10-01 19:16:45 +02:00 committed by Antoine GIRARD
parent 7156e2a71a
commit e90d88d5d5
3 changed files with 10 additions and 7 deletions

View file

@ -339,14 +339,17 @@ func (pr *PullRequest) GetLastCommitStatus() (status *CommitStatus, err error) {
return nil, err return nil, err
} }
repo := pr.HeadRepo
lastCommitID, err := headGitRepo.GetBranchCommitID(pr.HeadBranch) lastCommitID, err := headGitRepo.GetBranchCommitID(pr.HeadBranch)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var statusList []*CommitStatus err = pr.GetBaseRepo()
statusList, err = GetLatestCommitStatus(repo, lastCommitID, 0) if err != nil {
return nil, err
}
statusList, err := GetLatestCommitStatus(pr.BaseRepo, lastCommitID, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -212,8 +212,8 @@
<a class="title has-emoji" href="{{$.Link}}/{{.Index}}">{{.Title}}</a> <a class="title has-emoji" href="{{$.Link}}/{{.Index}}">{{.Title}}</a>
{{if .IsPull }} {{if .IsPull }}
{{if (index $.CommitStatus .ID)}} {{if (index $.CommitStatus .PullRequest.ID)}}
{{template "repo/commit_status" (index $.CommitStatus .ID)}} {{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}
{{end}} {{end}}
{{end}} {{end}}

View file

@ -68,8 +68,8 @@
<a class="title has-emoji" href="{{AppSubUrl}}/{{.Repo.Owner.Name}}/{{.Repo.Name}}/issues/{{.Index}}">{{.Title}}</a> <a class="title has-emoji" href="{{AppSubUrl}}/{{.Repo.Owner.Name}}/{{.Repo.Name}}/issues/{{.Index}}">{{.Title}}</a>
{{if .IsPull }} {{if .IsPull }}
{{if (index $.CommitStatus .ID)}} {{if (index $.CommitStatus .PullRequest.ID)}}
{{template "repo/commit_status" (index $.CommitStatus .ID)}} {{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}
{{end}} {{end}}
{{end}} {{end}}