1
0
Fork 0
forked from forgejo/forgejo

Show last commit status in pull request lists (#6465)

This commit is contained in:
Elias Norberg 2019-04-02 21:54:29 +02:00 committed by techknowlogick
parent 09fb036ad6
commit bf5af87eef
6 changed files with 144 additions and 0 deletions

View file

@ -292,6 +292,31 @@ func (pr *PullRequest) CanAutoMerge() bool {
return pr.Status == PullRequestStatusMergeable
}
// GetLastCommitStatus returns the last commit status for this pull request.
func (pr *PullRequest) GetLastCommitStatus() (status *CommitStatus, err error) {
if err = pr.GetHeadRepo(); err != nil {
return nil, err
}
headGitRepo, err := git.OpenRepository(pr.HeadRepo.RepoPath())
if err != nil {
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)
if err != nil {
return nil, err
}
return CalcCommitStatus(statusList), nil
}
// MergeStyle represents the approach to merge commits into base branch.
type MergeStyle string