aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryp053272023-03-03 19:01:33 +0900
committerGitHub2023-03-03 18:01:33 +0800
commit699f20234b9f7cdbbeeee3be004470c598fa1147 (patch)
treeab762f9225be16ced346adfe7bccf423bf439f75
parent0bfcbcc5e769bd258e4f530e0f007f5465f42de5 (diff)
Use correct README link to render the README (#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: Jason Song <i@wolfogre.com> Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
-rw-r--r--models/fixtures/repository.yml2
-rw-r--r--routers/web/repo/view.go2
-rw-r--r--tests/gitea-repositories-meta/user2/repo1.git/objects/40/3d76c604cb569323864e06a07b85d466924802bin0 -> 68 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo1.git/objects/78/fb907e3a3309eae4fe8fef030874cebbf1cd5ebin0 -> 158 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo1.git/objects/f3/fa0f5cc797fc4c02a1b8bec9de4b2072fcdbdfbin0 -> 53 bytes
-rw-r--r--tests/gitea-repositories-meta/user2/repo1.git/refs/heads/home-md-img-check1
-rw-r--r--tests/integration/repo_test.go20
7 files changed, 23 insertions, 2 deletions
diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml
index 58f9b919a..dd8facb7a 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 e3c61fa40..8663e1138 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 000000000..ea0bf76d0
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo1.git/objects/40/3d76c604cb569323864e06a07b85d466924802
Binary files differ
diff --git a/tests/gitea-repositories-meta/user2/repo1.git/objects/78/fb907e3a3309eae4fe8fef030874cebbf1cd5e b/tests/gitea-repositories-meta/user2/repo1.git/objects/78/fb907e3a3309eae4fe8fef030874cebbf1cd5e
new file mode 100644
index 000000000..6a25f7409
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo1.git/objects/78/fb907e3a3309eae4fe8fef030874cebbf1cd5e
Binary files differ
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 000000000..9b20f8af3
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo1.git/objects/f3/fa0f5cc797fc4c02a1b8bec9de4b2072fcdbdf
Binary files differ
diff --git a/tests/gitea-repositories-meta/user2/repo1.git/refs/heads/home-md-img-check b/tests/gitea-repositories-meta/user2/repo1.git/refs/heads/home-md-img-check
new file mode 100644
index 000000000..a254e4292
--- /dev/null
+++ b/tests/gitea-repositories-meta/user2/repo1.git/refs/heads/home-md-img-check
@@ -0,0 +1 @@
+78fb907e3a3309eae4fe8fef030874cebbf1cd5e
diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go
index 3692b11ec..7c3eac20c 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")
+}