Skip to content

Commit af22f33

Browse files
authored
Fix the route for pull-request's authors (#26016)
Close #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) ```
1 parent ec227d6 commit af22f33

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

routers/web/repo/issue.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3503,8 +3503,15 @@ type userSearchResponse struct {
35033503

35043504
// IssuePosters get posters for current repo's issues/pull requests
35053505
func IssuePosters(ctx *context.Context) {
3506+
issuePosters(ctx, false)
3507+
}
3508+
3509+
func PullPosters(ctx *context.Context) {
3510+
issuePosters(ctx, true)
3511+
}
3512+
3513+
func issuePosters(ctx *context.Context, isPullList bool) {
35063514
repo := ctx.Repo.Repository
3507-
isPullList := ctx.Params(":type") == "pulls"
35083515
search := strings.TrimSpace(ctx.FormString("q"))
35093516
posters, err := repo_model.GetIssuePostersWithSearch(ctx, repo, isPullList, search, setting.UI.DefaultShowFullName)
35103517
if err != nil {

routers/web/web.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,10 +1151,8 @@ func registerRoutes(m *web.Route) {
11511151

11521152
m.Group("/{username}/{reponame}", func() {
11531153
m.Group("", func() {
1154-
m.Group("/{type:issues|pulls}", func() {
1155-
m.Get("", repo.Issues)
1156-
m.Get("/posters", repo.IssuePosters)
1157-
})
1154+
m.Get("/issues/posters", repo.IssuePosters) // it can't use {type:issues|pulls} because other routes like "/pulls/{index}" has higher priority
1155+
m.Get("/{type:issues|pulls}", repo.Issues)
11581156
m.Get("/{type:issues|pulls}/{index}", repo.ViewIssue)
11591157
m.Group("/{type:issues|pulls}/{index}/content-history", func() {
11601158
m.Get("/overview", repo.GetContentHistoryOverview)
@@ -1276,6 +1274,7 @@ func registerRoutes(m *web.Route) {
12761274
return cancel
12771275
})
12781276

1277+
m.Get("/pulls/posters", repo.PullPosters)
12791278
m.Group("/pulls/{index}", func() {
12801279
m.Get("", repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewIssue)
12811280
m.Get(".diff", repo.DownloadPullDiff)

0 commit comments

Comments
 (0)