release: fix unable to edit release of a fork repository

This commit is contained in:
Unknwon 2017-02-23 11:35:33 -05:00
parent 162504e90c
commit 266c8f5a85
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
4 changed files with 7 additions and 20 deletions

View File

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

View File

@ -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

View File

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

View File

@ -1 +1 @@
0.9.166.0222 / 0.10 RC
0.9.166.0223 / 0.10 RC