From ae8a504422a48744e7068ee5ca4987e823106ee7 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Sun, 26 Feb 2023 02:51:38 +0900 Subject: [PATCH 1/6] add readme file name to treelink --- routers/web/repo/view.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index e3c61fa408bdb..8663e11382085 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 From 8f5db22a0638ea202056985f23d8148ae7136fae Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Thu, 2 Mar 2023 22:13:13 +0900 Subject: [PATCH 2/6] add test data --- .../40/3d76c604cb569323864e06a07b85d466924802 | Bin 0 -> 68 bytes .../78/fb907e3a3309eae4fe8fef030874cebbf1cd5e | Bin 0 -> 158 bytes .../f3/fa0f5cc797fc4c02a1b8bec9de4b2072fcdbdf | Bin 0 -> 53 bytes .../user2/repo1.git/refs/heads/home-md-img-check | 1 + 4 files changed, 1 insertion(+) 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/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 Date: Thu, 2 Mar 2023 22:21:16 +0900 Subject: [PATCH 3/6] change repo size --- models/fixtures/repository.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 58f9b919acfbc..dd8facb7a3134 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 From 477a9995e3340be681c54dfe50a966441dcba569 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Thu, 2 Mar 2023 23:03:34 +0900 Subject: [PATCH 4/6] add test func --- tests/integration/repo_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index 3692b11ecabe5..f603cac64fe18 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -256,3 +256,23 @@ func TestViewRepoDirectory(t *testing.T) { assert.Zero(t, repoTopics.Length()) assert.Zero(t, repoSummary.Length()) } + +func TestMarkDownImage(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + session := loginUser(t, "user2") + + req := NewRequest(t, "GET", "/user2/repo1/src/branch/home-md-img-check") + resp := session.MakeRequest(t, req, http.StatusOK) + + htmlDoc := NewHTMLParser(t, resp.Body) + _, exists := htmlDoc.doc.Find("img[src=\"/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg\"]").Attr("src") + assert.True(t, exists, "Repo home page markdown image link check failed") + + req = NewRequest(t, "GET", "/user2/repo1/src/branch/home-md-img-check/README.md") + resp = session.MakeRequest(t, req, http.StatusOK) + + htmlDoc = NewHTMLParser(t, resp.Body) + _, exists = htmlDoc.doc.Find("img[src=\"/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg\"]").Attr("src") + assert.True(t, exists, "Repo src page markdown image link check failed") +} From 55fed6522ed1b190412a4d90cef0f95cb94b7677 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 3 Mar 2023 10:30:37 +0900 Subject: [PATCH 5/6] Update tests/integration/repo_test.go Co-authored-by: silverwind --- tests/integration/repo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index f603cac64fe18..d385921852b75 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -266,7 +266,7 @@ func TestMarkDownImage(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - _, exists := htmlDoc.doc.Find("img[src=\"/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg\"]").Attr("src") + _, exists := htmlDoc.doc.Find(`img[src="/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg"]`).Attr("src") assert.True(t, exists, "Repo home page markdown image link check failed") req = NewRequest(t, "GET", "/user2/repo1/src/branch/home-md-img-check/README.md") From f62644345e543a87706f28f8bbc9d13fe49ae979 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 3 Mar 2023 10:30:43 +0900 Subject: [PATCH 6/6] Update tests/integration/repo_test.go Co-authored-by: silverwind --- tests/integration/repo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index d385921852b75..7c3eac20cfac2 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -273,6 +273,6 @@ func TestMarkDownImage(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) - _, exists = htmlDoc.doc.Find("img[src=\"/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg\"]").Attr("src") + _, exists = htmlDoc.doc.Find(`img[src="/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg"]`).Attr("src") assert.True(t, exists, "Repo src page markdown image link check failed") }