diff --git a/models/git.go b/models/git.go index d3bad6e0ce..46345d0ffc 100644 --- a/models/git.go +++ b/models/git.go @@ -56,6 +56,25 @@ func GetBranches(userName, repoName string) ([]string, error) { return brs, nil } +// GetTags returns all tags of given repository. +func GetTags(userName, repoName string) ([]string, error) { + repo, err := git.OpenRepository(RepoPath(userName, repoName)) + if err != nil { + return nil, err + } + + refs, err := repo.AllTags() + if err != nil { + return nil, err + } + + tags := make([]string, len(refs)) + for i, ref := range refs { + tags[i] = ref.Name + } + return tags, nil +} + func IsBranchExist(userName, repoName, branchName string) bool { repo, err := git.OpenRepository(RepoPath(userName, repoName)) if err != nil { diff --git a/models/repo.go b/models/repo.go index 8dd7da23f1..e3270b1838 100644 --- a/models/repo.go +++ b/models/repo.go @@ -74,6 +74,7 @@ type Repository struct { NumStars int NumForks int NumIssues int + NumReleases int `xorm:"NOT NULL"` NumClosedIssues int NumOpenIssues int `xorm:"-"` IsPrivate bool diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index f446d6a85b..2139742c70 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -79,6 +79,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { ctx.Handle(404, "RepoAssignment", err) return } + repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues ctx.Repo.Repository = repo ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 41b2c7e9b1..be92542641 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -74,7 +74,7 @@ func Issues(ctx *middleware.Context) { ctx.Data["Issues"] = showIssues ctx.Data["IssueCount"] = ctx.Repo.Repository.NumIssues - ctx.Data["OpenCount"] = ctx.Repo.Repository.NumIssues - ctx.Repo.Repository.NumClosedIssues + ctx.Data["OpenCount"] = ctx.Repo.Repository.NumOpenIssues ctx.Data["ClosedCount"] = ctx.Repo.Repository.NumClosedIssues ctx.Data["IssueCreatedCount"] = createdByCount ctx.Data["IsShowClosed"] = ctx.Query("state") == "closed" diff --git a/routers/repo/release.go b/routers/repo/release.go new file mode 100644 index 0000000000..8e8b93c9ea --- /dev/null +++ b/routers/repo/release.go @@ -0,0 +1,22 @@ +// 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. + +package repo + +import ( + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/middleware" +) + +func Releases(ctx *middleware.Context) { + ctx.Data["Title"] = "Releases" + ctx.Data["IsRepoToolbarReleases"] = true + tags, err := models.GetTags(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) + if err != nil { + ctx.Handle(404, "repo.Releases(GetTags)", err) + return + } + ctx.Data["Releases"] = tags + ctx.HTML(200, "release/list") +} diff --git a/templates/release/list.tmpl b/templates/release/list.tmpl new file mode 100644 index 0000000000..7d582e3ff8 --- /dev/null +++ b/templates/release/list.tmpl @@ -0,0 +1,10 @@ +{{template "base/head" .}} +{{template "base/navbar" .}} +{{template "repo/nav" .}} +{{template "repo/toolbar" .}} +