Browse Source

release: fix unable to edit release of a fork repository

pull/3854/merge
Unknwon 8 years ago
parent
commit
266c8f5a85
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 18
      cmd/web.go
  2. 2
      gogs.go
  3. 5
      routers/repo/release.go
  4. 2
      templates/.VERSION

18
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.

2
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

5
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.

2
templates/.VERSION

@ -1 +1 @@
0.9.166.0222 / 0.10 RC
0.9.166.0223 / 0.10 RC
Loading…
Cancel
Save