Skip to content

Commit 54a516e

Browse files
GiteaBotwxiaoguang
andauthored
Fix the route for pull-request's authors (go-gitea#26016) (go-gitea#26018)
Backport go-gitea#26016 by @wxiaoguang Close go-gitea#25906 ![image](https://github.com/go-gitea/gitea/assets/2114189/e689f3e1-9a90-46c0-89f4-2d61394d34d3) Succeeded logs: ``` [I] router: completed GET /root/test/issues/posters?&q=%20&_=1689853025011 for [::1]:59271, 200 OK in 127.7ms @ repo/issue.go:3505(repo.IssuePosters) [I] router: completed GET /root/test/pulls/posters?&q=%20&_=1689853968204 for [::1]:59269, 200 OK in 94.3ms @ repo/issue.go:3509(repo.PullPosters) ``` Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent ac129d4 commit 54a516e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

routers/web/repo/issue.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -3476,8 +3476,15 @@ type userSearchResponse struct {
34763476

34773477
// IssuePosters get posters for current repo's issues/pull requests
34783478
func IssuePosters(ctx *context.Context) {
3479+
issuePosters(ctx, false)
3480+
}
3481+
3482+
func PullPosters(ctx *context.Context) {
3483+
issuePosters(ctx, true)
3484+
}
3485+
3486+
func issuePosters(ctx *context.Context, isPullList bool) {
34793487
repo := ctx.Repo.Repository
3480-
isPullList := ctx.Params(":type") == "pulls"
34813488
search := strings.TrimSpace(ctx.FormString("q"))
34823489
posters, err := repo_model.GetIssuePostersWithSearch(ctx, repo, isPullList, search, setting.UI.DefaultShowFullName)
34833490
if err != nil {

routers/web/web.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -1143,10 +1143,8 @@ func registerRoutes(m *web.Route) {
11431143

11441144
m.Group("/{username}/{reponame}", func() {
11451145
m.Group("", func() {
1146-
m.Group("/{type:issues|pulls}", func() {
1147-
m.Get("", repo.Issues)
1148-
m.Get("/posters", repo.IssuePosters)
1149-
})
1146+
m.Get("/issues/posters", repo.IssuePosters) // it can't use {type:issues|pulls} because other routes like "/pulls/{index}" has higher priority
1147+
m.Get("/{type:issues|pulls}", repo.Issues)
11501148
m.Get("/{type:issues|pulls}/{index}", repo.ViewIssue)
11511149
m.Group("/{type:issues|pulls}/{index}/content-history", func() {
11521150
m.Get("/overview", repo.GetContentHistoryOverview)
@@ -1267,6 +1265,7 @@ func registerRoutes(m *web.Route) {
12671265
return cancel
12681266
})
12691267

1268+
m.Get("/pulls/posters", repo.PullPosters)
12701269
m.Group("/pulls/{index}", func() {
12711270
m.Get(".diff", repo.DownloadPullDiff)
12721271
m.Get(".patch", repo.DownloadPullPatch)

0 commit comments

Comments
 (0)