aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-08-30 04:31:32 +0300
committerLunny Xiao <xiaolunwen@gmail.com>2017-08-30 09:31:32 +0800
commit0c910afe11800517a0123ca57cd5d137fe748517 (patch)
treed6368c893d38efd1bf585afd84f14811337c982f
parent1cbe502cc232b9587417542b3cb367a828d2ac68 (diff)
downloadgitea-0c910afe11800517a0123ca57cd5d137fe748517.tar.gz
gitea-0c910afe11800517a0123ca57cd5d137fe748517.zip
Fix releases to be counted from database not tags (#2389) (#2424)
-rw-r--r--models/repo.go2
-rw-r--r--modules/context/repo.go10
-rw-r--r--templates/repo/header.tmpl2
3 files changed, 11 insertions, 3 deletions
diff --git a/models/repo.go b/models/repo.go
index 60c89836c0..afe9668fc5 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -193,7 +193,7 @@ type Repository struct {
NumMilestones int `xorm:"NOT NULL DEFAULT 0"`
NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
NumOpenMilestones int `xorm:"-"`
- NumTags int `xorm:"-"`
+ NumReleases int `xorm:"-"`
IsPrivate bool `xorm:"INDEX"`
IsBare bool `xorm:"INDEX"`
diff --git a/modules/context/repo.go b/modules/context/repo.go
index db643b50b8..b16d188428 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -275,7 +275,15 @@ func RepoAssignment() macaron.Handler {
return
}
ctx.Data["Tags"] = tags
- ctx.Repo.Repository.NumTags = len(tags)
+
+ count, err := models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{
+ IncludeDrafts: false,
+ })
+ if err != nil {
+ ctx.Handle(500, "GetReleaseCountByRepoID", err)
+ return
+ }
+ ctx.Repo.Repository.NumReleases = int(count)
ctx.Data["Title"] = owner.Name + "/" + repo.Name
ctx.Data["Repository"] = repo
diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl
index 7c91000488..8d457e7dc4 100644
--- a/templates/repo/header.tmpl
+++ b/templates/repo/header.tmpl
@@ -81,7 +81,7 @@
{{if and (.Repository.UnitEnabled $.UnitTypeReleases) (not .IsBareRepo) }}
<a class="{{if .PageIsReleaseList}}active{{end}} item" href="{{.RepoLink}}/releases">
- <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>
+ <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>
</a>
{{end}}