Skip to content

Commit 7c458e6

Browse files
DblKlunny
authored andcommitted
Display commit status on landing page of repo
1 parent a89692d commit 7c458e6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

routers/repo/view.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2017 The Gitea Authors. All rights reserved.
12
// Copyright 2014 The Gogs Authors. All rights reserved.
23
// Use of this source code is governed by a MIT-style
34
// license that can be found in the LICENSE file.
@@ -119,6 +120,21 @@ func renderDirectory(ctx *context.Context, treeLink string) {
119120
ctx.Data["LatestCommit"] = latestCommit
120121
ctx.Data["LatestCommitVerification"] = models.ParseCommitWithSignature(latestCommit)
121122
ctx.Data["LatestCommitUser"] = models.ValidateCommitWithEmail(latestCommit)
123+
commit := models.SignCommitWithStatuses{
124+
State: "",
125+
Statuses: make([]*models.CommitStatus, 0),
126+
}
127+
commit.Statuses, err = models.GetLatestCommitStatus(ctx.Repo.Repository, ctx.Repo.Commit.ID.String(), 0)
128+
if err != nil {
129+
log.Error(3, "GetLatestCommitStatus: %v", err)
130+
} else {
131+
for _, status := range commit.Statuses {
132+
if status.State.IsWorseThan(commit.State) {
133+
commit.State = status.State
134+
}
135+
}
136+
}
137+
ctx.Data["LatestCommitStatus"] = commit.State
122138

123139
// Check permission to add or upload new file.
124140
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {

templates/repo/view_list.tmpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@
2626
{{end}}
2727
</a>
2828
<span class="grey has-emoji">{{RenderCommitMessage false .LatestCommit.Summary .RepoLink $.Repository.ComposeMetas}}</span>
29+
{{if .LatestCommitStatus}}
30+
{{if eq .LatestCommitStatus "pending"}}
31+
<i class="commit-status circle icon yellow"></i>
32+
{{end}}
33+
{{if eq .LatestCommitStatus "success"}}
34+
<i class="commit-status check icon green"></i>
35+
{{end}}
36+
{{if eq .LatestCommitStatus "error"}}
37+
<i class="commit-status warning icon red"></i>
38+
{{end}}
39+
{{if eq .LatestCommitStatus "failure"}}
40+
<i class="commit-status remove icon red"></i>
41+
{{end}}
42+
{{if eq .LatestCommitStatus "warning"}}
43+
<i class="commit-status warning sign icon yellow"></i>
44+
{{end}}
45+
{{end}}
2946
</th>
3047
<th class="nine wide">
3148
</th>

0 commit comments

Comments
 (0)