aboutsummaryrefslogtreecommitdiffstats
path: root/services/gitdiff
diff options
context:
space:
mode:
authorRowan Bohde <rowan@allspice.io>2025-01-29 18:09:52 -0600
committerGitHub <noreply@github.com>2025-01-30 00:09:52 +0000
commitac2d97cb610d53d512545a6d0195173a5a690919 (patch)
tree063d2e9c879d345bcfaa9c988edd76c6c3734426 /services/gitdiff
parentdc7ddaee2aca7c3c1652a5b287c3047612c1c655 (diff)
downloadgitea-ac2d97cb610d53d512545a6d0195173a5a690919.tar.gz
gitea-ac2d97cb610d53d512545a6d0195173a5a690919.zip
Link to tree views of submodules if possible (#33424)
This is a follow-up to https://github.com/go-gitea/gitea/pull/33097. When linking a submodule at a commit in either the repo view, or a diff when adding a new submodule, link to the tree view of that submodules intead of the individual commit. This shows the user the full tree, instead of the diff of the commit. This makes the assumption that the tree for a given SHA is at `<repo_url>/tree/<sha>`. This URL format is supported by both Github & Gitlab, but not Gitea. To fix this, add a redirect from `<username>/<repo>/tree/<ref>` to `<username>/<repo>/src/<ref>`, so that Gitea can support this URL structure.
Diffstat (limited to 'services/gitdiff')
-rw-r--r--services/gitdiff/submodule_test.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/services/gitdiff/submodule_test.go b/services/gitdiff/submodule_test.go
index 89f32c0e0c..f0eab5557c 100644
--- a/services/gitdiff/submodule_test.go
+++ b/services/gitdiff/submodule_test.go
@@ -230,7 +230,7 @@ func TestSubmoduleInfo(t *testing.T) {
assert.EqualValues(t, "name", sdi.SubmoduleRepoLinkHTML(ctx))
sdi.SubmoduleFile = git.NewCommitSubmoduleFile("https://github.com/owner/repo", "1234")
- assert.EqualValues(t, `<a href="https://github.com/owner/repo/commit/1111">1111</a>`, sdi.CommitRefIDLinkHTML(ctx, "1111"))
+ assert.EqualValues(t, `<a href="https://github.com/owner/repo/tree/1111">1111</a>`, sdi.CommitRefIDLinkHTML(ctx, "1111"))
assert.EqualValues(t, `<a href="https://github.com/owner/repo/compare/aaaa...bbbb">aaaa...bbbb</a>`, sdi.CompareRefIDLinkHTML(ctx))
assert.EqualValues(t, `<a href="https://github.com/owner/repo">name</a>`, sdi.SubmoduleRepoLinkHTML(ctx))
}