From 1322cd7a58f6c2041624eddaf9393cc8947e5a5d Mon Sep 17 00:00:00 2001 From: Giteabot Date: Sat, 4 Mar 2023 00:38:11 -0500 Subject: [PATCH] Use correct README link to render the README (#23152) (#23264) Backport #23152 `renderReadmeFile` needs `readmeTreelink` as parameter but gets `treeLink`. The values of them look like as following: `treeLink`: `/{OwnerName}/{RepoName}/src/branch/{BranchName}` `readmeTreelink`: `/{OwnerName}/{RepoName}/src/branch/{BranchName}/{ReadmeFileName}` `path.Dir` in https://github.com/go-gitea/gitea/blob/8540fc45b11eff9a73753ca139f8ea5c38509bf5/routers/web/repo/view.go#L316 should convert `readmeTreelink` into `/{OwnerName}/{RepoName}/src/branch/{BranchName}` instead of the current `/{OwnerName}/{RepoName}/src/branch`. Fixes #23151 Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: Jason Song Co-authored-by: John Olheiser Co-authored-by: silverwind --- models/fixtures/repository.yml | 2 +- routers/web/repo/view.go | 2 +- .../40/3d76c604cb569323864e06a07b85d466924802 | Bin 0 -> 68 bytes .../78/fb907e3a3309eae4fe8fef030874cebbf1cd5e | Bin 0 -> 158 bytes .../f3/fa0f5cc797fc4c02a1b8bec9de4b2072fcdbdf | Bin 0 -> 53 bytes .../repo1.git/refs/heads/home-md-img-check | 1 + tests/integration/repo_test.go | 20 ++++++++++++++++++ 7 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/gitea-repositories-meta/user2/repo1.git/objects/40/3d76c604cb569323864e06a07b85d466924802 create mode 100644 tests/gitea-repositories-meta/user2/repo1.git/objects/78/fb907e3a3309eae4fe8fef030874cebbf1cd5e create mode 100644 tests/gitea-repositories-meta/user2/repo1.git/objects/f3/fa0f5cc797fc4c02a1b8bec9de4b2072fcdbdf create mode 100644 tests/gitea-repositories-meta/user2/repo1.git/refs/heads/home-md-img-check diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 58f9b919ac..dd8facb7a3 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -25,7 +25,7 @@ fork_id: 0 is_template: false template_id: 0 - size: 6708 + size: 7028 is_fsck_enabled: true close_issues_via_commit_in_any_branch: false diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index e3c61fa408..8663e11382 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -186,7 +186,7 @@ func renderDirectory(ctx *context.Context, treeLink string) { return } - renderReadmeFile(ctx, readmeFile, treeLink) + renderReadmeFile(ctx, readmeFile, fmt.Sprintf("%s/%s", treeLink, readmeFile.name)) } // localizedExtensions prepends the provided language code with and without a diff --git a/tests/gitea-repositories-meta/user2/repo1.git/objects/40/3d76c604cb569323864e06a07b85d466924802 b/tests/gitea-repositories-meta/user2/repo1.git/objects/40/3d76c604cb569323864e06a07b85d466924802 new file mode 100644 index 0000000000000000000000000000000000000000..ea0bf76d0cc85bb9d51720cae227d440a93a3388 GIT binary patch literal 68 zcmV-K0K5Nq0ZYosPf{?mU{F>lN-fAYEpczHPS& zC9f~@aEDl;W009N39E*sXI<5;4X;{IO4!g5>D~|jp1>4Yqlns~AsAelglXl4oEcm7 zp{8}D{+yrt0l#;or3hS3t5L3)uaC!@?b|zK77<1wfmdvZ>7?h|^#4_o MxNRTl4+U^QjwQiQZvX%Q literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/repo1.git/objects/f3/fa0f5cc797fc4c02a1b8bec9de4b2072fcdbdf b/tests/gitea-repositories-meta/user2/repo1.git/objects/f3/fa0f5cc797fc4c02a1b8bec9de4b2072fcdbdf new file mode 100644 index 0000000000000000000000000000000000000000..9b20f8af3f2d52f51ef5053a55a15ed946fda5a7 GIT binary patch literal 53 zcmb