diff options
author | Rémy Boulanouar <rboulanouar@gmail.com> | 2017-09-14 08:51:32 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-09-14 14:51:31 +0800 |
commit | be3319b3d545289b772d7a92b4b62205863954d9 (patch) | |
tree | 89473f47f6303ea5ab57ade7901de1a3a48dd673 /routers | |
parent | a89692d15884271a2927b5f7332ed074116d324c (diff) | |
download | gitea-be3319b3d545289b772d7a92b4b62205863954d9.tar.gz gitea-be3319b3d545289b772d7a92b4b62205863954d9.zip |
Display commit status on landing page of repo (#1784)
* Display commit status on landing page of repo
* improve last status of commits and add link to ci
* fix last commit status since the order of ids are desc
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/commit.go | 10 | ||||
-rw-r--r-- | routers/repo/view.go | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 1835e47318..95630fcece 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -13,7 +13,9 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "github.com/Unknwon/paginater" ) @@ -208,6 +210,14 @@ func Diff(ctx *context.Context) { if len(commitID) != 40 { commitID = commit.ID.String() } + + statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository, ctx.Repo.Commit.ID.String(), 0) + if err != nil { + log.Error(3, "GetLatestCommitStatus: %v", err) + } + + ctx.Data["CommitStatus"] = models.CalcCommitStatus(statuses) + diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), commitID, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles) diff --git a/routers/repo/view.go b/routers/repo/view.go index 84e5ba85ce..3a9e0e1d3b 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -1,3 +1,4 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. // Copyright 2014 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -120,6 +121,13 @@ func renderDirectory(ctx *context.Context, treeLink string) { ctx.Data["LatestCommitVerification"] = models.ParseCommitWithSignature(latestCommit) ctx.Data["LatestCommitUser"] = models.ValidateCommitWithEmail(latestCommit) + statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository, ctx.Repo.Commit.ID.String(), 0) + if err != nil { + log.Error(3, "GetLatestCommitStatus: %v", err) + } + + ctx.Data["LatestCommitStatus"] = models.CalcCommitStatus(statuses) + // Check permission to add or upload new file. if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch { ctx.Data["CanAddFile"] = true |