mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-30 14:13:52 +00:00
fix: redirect from /{username}/{reponame}/pulls/{index} to issue if index is a issue (#8874)
Redirection from issue to pull is already working, but from pull to issue is not working. This is now fixed. Resolves forgejo/forgejo#7386 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8874 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: zokki <zokki.softwareschmiede@gmail.com> Co-committed-by: zokki <zokki.softwareschmiede@gmail.com>
This commit is contained in:
parent
e3bfa5133f
commit
fb1095d141
2 changed files with 33 additions and 1 deletions
|
@ -360,7 +360,7 @@ func getPullInfo(ctx *context.Context) (issue *issues_model.Issue, ok bool) {
|
||||||
ctx.Data["Issue"] = issue
|
ctx.Data["Issue"] = issue
|
||||||
|
|
||||||
if !issue.IsPull {
|
if !issue.IsPull {
|
||||||
ctx.NotFound("ViewPullCommits", nil)
|
ctx.Redirect(issue.Link())
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1536,3 +1536,35 @@ func TestIssueTimelineLabels(t *testing.T) {
|
||||||
filterLinks := htmlDoc.Find(".timeline .labels-list a")
|
filterLinks := htmlDoc.Find(".timeline .labels-list a")
|
||||||
assert.Equal(t, 9, filterLinks.Length())
|
assert.Equal(t, 9, filterLinks.Length())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssueAndPullRedirect(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/user2/repo1/issues/1")
|
||||||
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/2")
|
||||||
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/1")
|
||||||
|
resp := MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
assert.Equal(t, "/user2/repo1/issues/1", resp.Header().Get("Location"))
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/1/commits")
|
||||||
|
resp = MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
assert.Equal(t, "/user2/repo1/issues/1", resp.Header().Get("Location"))
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/1/files")
|
||||||
|
resp = MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
assert.Equal(t, "/user2/repo1/issues/1", resp.Header().Get("Location"))
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/issues/2")
|
||||||
|
resp = MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
assert.Equal(t, "/user2/repo1/pulls/2", resp.Header().Get("Location"))
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/issues/9999999")
|
||||||
|
MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/9999999")
|
||||||
|
MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue