Skip to content

Commit 14cf0d1

Browse files
committed
Fix releases to be counted from database not tags
1 parent ced50e0 commit 14cf0d1

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

models/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ type Repository struct {
194194
NumMilestones int `xorm:"NOT NULL DEFAULT 0"`
195195
NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
196196
NumOpenMilestones int `xorm:"-"`
197-
NumTags int `xorm:"-"`
197+
NumReleases int `xorm:"-"`
198198

199199
IsPrivate bool `xorm:"INDEX"`
200200
IsBare bool `xorm:"INDEX"`

modules/context/repo.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,15 @@ func RepoAssignment() macaron.Handler {
275275
return
276276
}
277277
ctx.Data["Tags"] = tags
278-
ctx.Repo.Repository.NumTags = len(tags)
278+
279+
count, err := models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{
280+
IncludeDrafts: false,
281+
})
282+
if err != nil {
283+
ctx.Handle(500, "GetReleaseCountByRepoID", err)
284+
return
285+
}
286+
ctx.Repo.Repository.NumReleases = int(count)
279287

280288
ctx.Data["Title"] = owner.Name + "/" + repo.Name
281289
ctx.Data["Repository"] = repo

templates/repo/header.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
{{if and (.Repository.UnitEnabled $.UnitTypeReleases) (not .IsBareRepo) }}
8383
<a class="{{if .PageIsReleaseList}}active{{end}} item" href="{{.RepoLink}}/releases">
84-
<i class="octicon octicon-tag"></i> {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .Repository.NumTags}}gray{{else}}blue{{end}} small label">{{.Repository.NumTags}}</span>
84+
<i class="octicon octicon-tag"></i> {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .Repository.NumReleases}}gray{{else}}blue{{end}} small label">{{.Repository.NumReleases}}</span>
8585
</a>
8686
{{end}}
8787

0 commit comments

Comments
 (0)