From e78d1c8210dc0ccaef6488e98ac333cf6242d88c Mon Sep 17 00:00:00 2001 From: Robert Wolff Date: Wed, 28 May 2025 14:50:05 +0200 Subject: [PATCH] fix: pull request cross references (#7979) Closes #7974. ### Tests - I added test coverage for Go changes... - [x] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7979 Reviewed-by: Earl Warren Co-authored-by: Robert Wolff Co-committed-by: Robert Wolff --- modules/references/references.go | 3 ++- modules/references/references_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/references/references.go b/modules/references/references.go index 81267f0065..7df5119393 100644 --- a/modules/references/references.go +++ b/modules/references/references.go @@ -460,7 +460,8 @@ func findAllIssueReferencesBytes(content []byte, links []string) []*rawReference } parts := strings.Split(u.EscapedPath(), "/") // /user/repo/issues/3 - if len(parts) != 5 || parts[0] != "" { + // /user/repo/pulls/7/files/... + if len(parts) < 5 || parts[0] != "" { continue } var sep string diff --git a/modules/references/references_test.go b/modules/references/references_test.go index 77f6bfbae3..bb22c0bd59 100644 --- a/modules/references/references_test.go +++ b/modules/references/references_test.go @@ -132,6 +132,30 @@ func TestFindAllIssueReferences(t *testing.T) { {203, "user4", "repo5", "203", true, XRefActionNone, nil, nil, ""}, }, }, + { + "This http://gitea.com:3000/user4/repo5/pulls/202#x yes.", + []testResult{ + {202, "user4", "repo5", "202", true, XRefActionNone, nil, nil, ""}, + }, + }, + { + "This http://gitea.com:3000/user4/repo5/pulls/202/commits yes.", + []testResult{ + {202, "user4", "repo5", "202", true, XRefActionNone, nil, nil, ""}, + }, + }, + { + "This http://gitea.com:3000/user4/repo5/pulls/202/files yes.", + []testResult{ + {202, "user4", "repo5", "202", true, XRefActionNone, nil, nil, ""}, + }, + }, + { + "This http://gitea.com:3000/user4/repo5/pulls/202/files#diff- yes.", + []testResult{ + {202, "user4", "repo5", "202", true, XRefActionNone, nil, nil, ""}, + }, + }, { "This http://GiTeA.COM:3000/user4/repo6/pulls/205 yes.", []testResult{