summaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-06-30 15:57:59 +0800
committerzeripath <art27@cantab.net>2019-06-30 08:57:59 +0100
commitff85dd3e12c05be98d9132de2e629523d096f712 (patch)
treec0b5d69eef2fd859204437bd8b206e06a7b8a47d /routers/repo
parent1e46eedce721e22e3e1e94eec6e0afccd36147c1 (diff)
downloadgitea-ff85dd3e12c05be98d9132de2e629523d096f712.tar.gz
gitea-ff85dd3e12c05be98d9132de2e629523d096f712.zip
Add commit statuses reports on pull request view (#6845)
* Add commit statuses reports on pull view * Add some translations * improve the UI * fix fmt * fix tests * add a new test git repo to fix tests * fix bug when headRepo or headBranch missing * fix tests * fix tests * fix consistency * fix tests * fix tests * change the test repo * fix tests * fix tests * fix migration * keep db size consistency * fix translation * change commit hash status table unique index * remove unused table * use char instead varchar * make hashCommitStatusContext private * split merge section with status check on pull view ui * fix tests; fix arc-green theme on pull ui
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/pull.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 36b0d047b1..4c377bb364 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -321,15 +321,37 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
setMergeTarget(ctx, pull)
var headGitRepo *git.Repository
+ var headBranchExist bool
+ // HeadRepo may be missing
if pull.HeadRepo != nil {
headGitRepo, err = git.OpenRepository(pull.HeadRepo.RepoPath())
if err != nil {
ctx.ServerError("OpenRepository", err)
return nil
}
+
+ headBranchExist = headGitRepo.IsBranchExist(pull.HeadBranch)
+
+ if headBranchExist {
+ sha, err := headGitRepo.GetBranchCommitID(pull.HeadBranch)
+ if err != nil {
+ ctx.ServerError("GetBranchCommitID", err)
+ return nil
+ }
+
+ commitStatuses, err := models.GetLatestCommitStatus(repo, sha, 0)
+ if err != nil {
+ ctx.ServerError("GetLatestCommitStatus", err)
+ return nil
+ }
+ if len(commitStatuses) > 0 {
+ ctx.Data["LatestCommitStatuses"] = commitStatuses
+ ctx.Data["LatestCommitStatus"] = models.CalcCommitStatus(commitStatuses)
+ }
+ }
}
- if pull.HeadRepo == nil || !headGitRepo.IsBranchExist(pull.HeadBranch) {
+ if pull.HeadRepo == nil || !headBranchExist {
ctx.Data["IsPullRequestBroken"] = true
ctx.Data["HeadTarget"] = "deleted"
ctx.Data["NumCommits"] = 0