Skip to content

Commit c2e8dfc

Browse files
committed
temp fix
1 parent 5191149 commit c2e8dfc

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

routers/web/web.go

+12-15
Original file line numberDiff line numberDiff line change
@@ -1333,39 +1333,36 @@ func registerRoutes(m *web.Router) {
13331333
m.Group("/{username}/{reponame}", func() { // repo tags
13341334
m.Group("/tags", func() {
13351335
m.Get("", repo.TagsList)
1336-
m.Get("/list", repo.GetTagList)
13371336
m.Get(".rss", feedEnabled, repo.TagsListFeedRSS)
13381337
m.Get(".atom", feedEnabled, repo.TagsListFeedAtom)
1339-
}, ctxDataSet("EnableFeed", setting.Other.EnableFeed),
1340-
repo.MustBeNotEmpty, context.RepoRefByType(git.RefTypeTag, context.RepoRefByTypeOptions{IgnoreNotExistErr: true}))
1341-
m.Post("/tags/delete", repo.DeleteTag, reqSignIn,
1342-
repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoCodeWriter, context.RepoRef())
1343-
}, optSignIn, context.RepoAssignment, reqUnitCodeReader)
1338+
m.Get("/list", repo.GetTagList)
1339+
}, ctxDataSet("EnableFeed", setting.Other.EnableFeed))
1340+
m.Post("/tags/delete", reqSignIn, reqRepoCodeWriter, context.RepoMustNotBeArchived(), repo.DeleteTag)
1341+
}, optSignIn, context.RepoAssignment, repo.MustBeNotEmpty, reqUnitCodeReader)
13441342
// end "/{username}/{reponame}": repo tags
13451343

13461344
m.Group("/{username}/{reponame}", func() { // repo releases
13471345
m.Group("/releases", func() {
13481346
m.Get("", repo.Releases)
1349-
m.Get("/tag/*", repo.SingleRelease)
1350-
m.Get("/latest", repo.LatestRelease)
13511347
m.Get(".rss", feedEnabled, repo.ReleasesFeedRSS)
13521348
m.Get(".atom", feedEnabled, repo.ReleasesFeedAtom)
1353-
}, ctxDataSet("EnableFeed", setting.Other.EnableFeed),
1354-
repo.MustBeNotEmpty, context.RepoRefByType(git.RefTypeTag, context.RepoRefByTypeOptions{IgnoreNotExistErr: true}))
1355-
m.Get("/releases/attachments/{uuid}", repo.MustBeNotEmpty, repo.GetAttachment)
1356-
m.Get("/releases/download/{vTag}/{fileName}", repo.MustBeNotEmpty, repo.RedirectDownload)
1349+
m.Get("/tag/*", context.RepoRefByType(git.RefTypeTag), repo.SingleRelease)
1350+
m.Get("/latest", repo.LatestRelease)
1351+
}, ctxDataSet("EnableFeed", setting.Other.EnableFeed))
1352+
m.Get("/releases/attachments/{uuid}", repo.GetAttachment)
1353+
m.Get("/releases/download/{vTag}/{fileName}", repo.RedirectDownload)
13571354
m.Group("/releases", func() {
13581355
m.Get("/new", repo.NewRelease)
13591356
m.Post("/new", web.Bind(forms.NewReleaseForm{}), repo.NewReleasePost)
13601357
m.Post("/delete", repo.DeleteRelease)
13611358
m.Post("/attachments", repo.UploadReleaseAttachment)
13621359
m.Post("/attachments/remove", repo.DeleteAttachment)
1363-
}, reqSignIn, repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, context.RepoRef())
1360+
}, reqSignIn, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, context.RepoRef())
13641361
m.Group("/releases", func() {
13651362
m.Get("/edit/*", repo.EditRelease)
13661363
m.Post("/edit/*", web.Bind(forms.EditReleaseForm{}), repo.EditReleasePost)
1367-
}, reqSignIn, repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, repo.CommitInfoCache)
1368-
}, optSignIn, context.RepoAssignment, reqRepoReleaseReader)
1364+
}, reqSignIn, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, repo.CommitInfoCache)
1365+
}, optSignIn, context.RepoAssignment, repo.MustBeNotEmpty, reqRepoReleaseReader)
13691366
// end "/{username}/{reponame}": repo releases
13701367

13711368
m.Group("/{username}/{reponame}", func() { // to maintain compatibility with old attachments

services/context/repo.go

+2-12
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,8 @@ func RepoAssignment(ctx *Context) {
679679

680680
const headRefName = "HEAD"
681681

682-
// RepoRef handles repository reference names when the ref name is not
683-
// explicitly given
684682
func RepoRef() func(*Context) {
685-
// since no ref name is explicitly specified, ok to just use branch
683+
setting.PanicInDevOrTesting("RepoRef should not be used, the handler should explicit use the ref it needs")
686684
return RepoRefByType(git.RefTypeBranch)
687685
}
688686

@@ -776,10 +774,6 @@ func getRefName(ctx *Base, repo *Repository, path string, refType git.RefType) s
776774
return ""
777775
}
778776

779-
type RepoRefByTypeOptions struct {
780-
IgnoreNotExistErr bool
781-
}
782-
783777
func repoRefFullName(typ git.RefType, shortName string) git.RefName {
784778
switch typ {
785779
case git.RefTypeBranch:
@@ -796,8 +790,7 @@ func repoRefFullName(typ git.RefType, shortName string) git.RefName {
796790

797791
// RepoRefByType handles repository reference name for a specific type
798792
// of repository reference
799-
func RepoRefByType(detectRefType git.RefType, opts ...RepoRefByTypeOptions) func(*Context) {
800-
opt := util.OptionalArg(opts)
793+
func RepoRefByType(detectRefType git.RefType) func(*Context) {
801794
return func(ctx *Context) {
802795
var err error
803796
refType := detectRefType
@@ -908,9 +901,6 @@ func RepoRefByType(detectRefType git.RefType, opts ...RepoRefByTypeOptions) func
908901
ctx.RespHeader().Set("Link", fmt.Sprintf(`<%s>; rel="canonical"`, canonicalURL))
909902
}
910903
} else {
911-
if opt.IgnoreNotExistErr {
912-
return
913-
}
914904
ctx.NotFound("RepoRef invalid repo", fmt.Errorf("branch or tag not exist: %s", refShortName))
915905
return
916906
}

0 commit comments

Comments
 (0)