From 266c8f5a85d259d1e997985062c924630625fc71 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 23 Feb 2017 11:35:33 -0500 Subject: [PATCH] release: fix unable to edit release of a fork repository --- cmd/web.go | 18 +----------------- gogs.go | 2 +- routers/repo/release.go | 5 ++++- templates/.VERSION | 2 +- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/cmd/web.go b/cmd/web.go index 7f00e2398..cdbe1bfbf 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -527,25 +527,9 @@ func runWeb(ctx *cli.Context) error { m.Get("/new", repo.NewRelease) m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost) m.Post("/delete", repo.DeleteRelease) - }, reqRepoWriter, context.RepoRef()) - - m.Group("/releases", func() { m.Get("/edit/*", repo.EditRelease) m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost) - }, reqRepoWriter, func(ctx *context.Context) { - var err error - ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch) - if err != nil { - ctx.Handle(500, "GetBranchCommit", err) - return - } - ctx.Repo.CommitsCount, err = ctx.Repo.Commit.CommitsCount() - if err != nil { - ctx.Handle(500, "CommitsCount", err) - return - } - ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount - }) + }, reqRepoWriter, context.RepoRef()) // FIXME: Should use ctx.Repo.PullRequest to unify template, currently we have inconsistent URL // for PR in same repository. After select branch on the page, the URL contains redundant head user name. diff --git a/gogs.go b/gogs.go index acad1c1b3..452f7dd77 100644 --- a/gogs.go +++ b/gogs.go @@ -16,7 +16,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.9.166.0222 / 0.10 RC" +const APP_VER = "0.9.166.0223 / 0.10 RC" func init() { setting.AppVer = APP_VER diff --git a/routers/repo/release.go b/routers/repo/release.go index 8df329691..bf58cdcc8 100644 --- a/routers/repo/release.go +++ b/routers/repo/release.go @@ -59,6 +59,7 @@ func Releases(ctx *context.Context) { return } + // FIXME: should only get releases match tags result and drafts. releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID) if err != nil { ctx.Handle(500, "GetReleasesByRepoID", err) @@ -72,7 +73,9 @@ func Releases(ctx *context.Context) { tags := make([]*models.Release, len(tagsResult.Tags)) for i, rawTag := range tagsResult.Tags { for j, r := range releases { - if r == nil || (r.IsDraft && !ctx.Repo.IsOwner()) { + if r == nil || + (r.IsDraft && !ctx.Repo.IsOwner()) || + (!r.IsDraft && r.TagName != rawTag) { continue } releases[j] = nil // Mark as used. diff --git a/templates/.VERSION b/templates/.VERSION index 2304768c2..ac650749d 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.9.166.0222 / 0.10 RC \ No newline at end of file +0.9.166.0223 / 0.10 RC \ No newline at end of file