Skip to content

Commit

Permalink
Fix the route for pull-request's authors (#26016)
Browse files Browse the repository at this point in the history
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)
```
  • Loading branch information
wxiaoguang authored Jul 20, 2023
1 parent ec227d6 commit af22f33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 8 additions & 1 deletion routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -3503,8 +3503,15 @@ type userSearchResponse struct {

// IssuePosters get posters for current repo's issues/pull requests
func IssuePosters(ctx *context.Context) {
issuePosters(ctx, false)
}

func PullPosters(ctx *context.Context) {
issuePosters(ctx, true)
}

func issuePosters(ctx *context.Context, isPullList bool) {
repo := ctx.Repo.Repository
isPullList := ctx.Params(":type") == "pulls"
search := strings.TrimSpace(ctx.FormString("q"))
posters, err := repo_model.GetIssuePostersWithSearch(ctx, repo, isPullList, search, setting.UI.DefaultShowFullName)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -1151,10 +1151,8 @@ func registerRoutes(m *web.Route) {

m.Group("/{username}/{reponame}", func() {
m.Group("", func() {
m.Group("/{type:issues|pulls}", func() {
m.Get("", repo.Issues)
m.Get("/posters", repo.IssuePosters)
})
m.Get("/issues/posters", repo.IssuePosters) // it can't use {type:issues|pulls} because other routes like "/pulls/{index}" has higher priority
m.Get("/{type:issues|pulls}", repo.Issues)
m.Get("/{type:issues|pulls}/{index}", repo.ViewIssue)
m.Group("/{type:issues|pulls}/{index}/content-history", func() {
m.Get("/overview", repo.GetContentHistoryOverview)
Expand Down Expand Up @@ -1276,6 +1274,7 @@ func registerRoutes(m *web.Route) {
return cancel
})

m.Get("/pulls/posters", repo.PullPosters)
m.Group("/pulls/{index}", func() {
m.Get("", repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewIssue)
m.Get(".diff", repo.DownloadPullDiff)
Expand Down

0 comments on commit af22f33

Please sign in to comment.