diff --git a/modules/markup/html.go b/modules/markup/html.go
index 5bca4c4596..4c25ab9985 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -1125,7 +1125,7 @@ func fullHashPatternProcessor(ctx *RenderContext, node *html.Node) {
if hash != "" {
text += " (" + hash + ")"
}
- replaceContent(node, start, end, createCodeLink(urlFull, text, "commit"))
+ replaceContent(node, start, end, createCodeLink(urlFull, text, ""))
node = node.NextSibling.NextSibling
}
}
@@ -1409,7 +1409,7 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) {
}
link := util.URLJoin(ctx.Links.Prefix(), ctx.Metas["user"], ctx.Metas["repo"], "commit", hash)
- replaceContent(node, m[2], m[3], createCodeLink(link, base.ShortSha(hash), "commit"))
+ replaceContent(node, m[2], m[3], createCodeLink(link, base.ShortSha(hash), ""))
start = 0
node = node.NextSibling.NextSibling
}
diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go
index 570e8c5e68..ed8ac206b9 100644
--- a/modules/markup/html_internal_test.go
+++ b/modules/markup/html_internal_test.go
@@ -340,52 +340,52 @@ func TestRender_AutoLink(t *testing.T) {
t.Run("Commit", func(t *testing.T) {
// render valid commit URLs
tmp := util.URLJoin(TestRepoURL, "commit", "d8a994ef243349f321568f9e36d5c3f444b99cae")
- assert(tmp, "d8a994ef24", TestRepoURLWithoutSlash)
- assert(tmp, ""+TestOrgRepo+"@d8a994ef24", "/forgejo/forgejo")
+ assert(tmp, "d8a994ef24", TestRepoURLWithoutSlash)
+ assert(tmp, ""+TestOrgRepo+"@d8a994ef24", "/forgejo/forgejo")
assert(
tmp+"#diff-2",
- "d8a994ef24 (diff-2)",
+ "d8a994ef24 (diff-2)",
TestRepoURL,
)
assert(
tmp+"#diff-953bb4f01b7c77fa18f0cd54211255051e647dbc",
- "d8a994ef24 (diff-953bb4f01b)",
+ "d8a994ef24 (diff-953bb4f01b)",
TestRepoURLWithoutSlash,
)
// render other commit URLs
tmp = "https://external-link.gitea.io/go-gitea/gitea/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2"
- assert(tmp, "external-link.gitea.io/go-gitea/gitea@d8a994ef24 (diff-2)", TestOrgRepo)
+ assert(tmp, "external-link.gitea.io/go-gitea/gitea@d8a994ef24 (diff-2)", TestOrgRepo)
defer test.MockVariableValue(&setting.AppURL, "https://external-link.gitea.io/")()
- assert(tmp, "d8a994ef24 (diff-2)", "https://external-link.gitea.io/go-gitea/gitea")
+ assert(tmp, "d8a994ef24 (diff-2)", "https://external-link.gitea.io/go-gitea/gitea")
tmp = TestAppURL + "gogits/gogs/src/commit/190d9492934af498c3f669d6a2431dc5459e5b20"
- assert(tmp, "localhost:3000/gogits/gogs@190d949293", "https://external-link.gitea.io/go-gitea/gitea")
+ assert(tmp, "localhost:3000/gogits/gogs@190d949293", "https://external-link.gitea.io/go-gitea/gitea")
defer test.MockVariableValue(&setting.AppURL, TestAppURL)()
- assert(tmp, "190d949293", "http://localhost:3000/gogits/gogs")
+ assert(tmp, "190d949293", "http://localhost:3000/gogits/gogs")
tmp = "http://localhost:3000/sub/gogits/gogs/src/commit/190d9492934af498c3f669d6a2431dc5459e5b20"
- assert(tmp, "localhost:3000/sub/gogits/gogs@190d949293", TestRepoURLWithoutSlash)
- assert(tmp, "localhost:3000/sub/gogits/gogs@190d949293", "https://external-link.gitea.io/go-gitea/gitea")
+ assert(tmp, "localhost:3000/sub/gogits/gogs@190d949293", TestRepoURLWithoutSlash)
+ assert(tmp, "localhost:3000/sub/gogits/gogs@190d949293", "https://external-link.gitea.io/go-gitea/gitea")
defer test.MockVariableValue(&setting.AppURL, TestAppURL+"sub/")()
- assert(tmp, "190d949293", "http://localhost:3000/sub/gogits/gogs")
+ assert(tmp, "190d949293", "http://localhost:3000/sub/gogits/gogs")
tmp = "http://localhost:3000/sub1/sub2/sub3/gogits/gogs/src/commit/190d9492934af498c3f669d6a2431dc5459e5b20"
defer test.MockVariableValue(&setting.AppURL, TestAppURL+"sub1/sub2/sub3/")()
- assert(tmp, "190d949293", "http://localhost:3000/sub1/sub2/sub3/gogits/gogs")
+ assert(tmp, "190d949293", "http://localhost:3000/sub1/sub2/sub3/gogits/gogs")
defer test.MockVariableValue(&setting.AppURL, TestAppURL)()
- assert(tmp, "localhost:3000/sub1/sub2/sub3/gogits/gogs@190d949293", "http://localhost:3000/sub1/gogits/gogs")
- assert(tmp, "localhost:3000/sub1/sub2/sub3/gogits/gogs@190d949293", "https://external-link.gitea.io/go-gitea/gitea")
+ assert(tmp, "localhost:3000/sub1/sub2/sub3/gogits/gogs@190d949293", "http://localhost:3000/sub1/gogits/gogs")
+ assert(tmp, "localhost:3000/sub1/sub2/sub3/gogits/gogs@190d949293", "https://external-link.gitea.io/go-gitea/gitea")
// if the repository happens to be named like one of the known app routes (e.g. `src`),
// we can parse the URL correctly, if there is no sub path
tmp = "http://localhost:3000/gogits/src/commit/190d9492934af498c3f669d6a2431dc5459e5b20"
- assert(tmp, "gogits/src@190d949293", TestRepoURL)
+ assert(tmp, "gogits/src@190d949293", TestRepoURL)
tmp = "http://localhost:3000/gogits/src/src/commit/190d9492934af498c3f669d6a2431dc5459e5b20"
- assert(tmp, "gogits/src@190d949293", TestRepoURL)
+ assert(tmp, "gogits/src@190d949293", TestRepoURL)
// but if there is a sub path, we cannot reliably distinguish the repo name from the app route
tmp = "http://localhost:3000/sub/gogits/src/commit/190d9492934af498c3f669d6a2431dc5459e5b20"
- assert(tmp, "sub/gogits@190d949293", TestRepoURL)
+ assert(tmp, "sub/gogits@190d949293", TestRepoURL)
})
t.Run("Compare", func(t *testing.T) {
diff --git a/modules/templates/util_date.go b/modules/templates/util_date.go
index 982a1b8050..0f757d914d 100644
--- a/modules/templates/util_date.go
+++ b/modules/templates/util_date.go
@@ -26,6 +26,11 @@ func (du *DateUtils) AbsoluteShort(time any) template.HTML {
return dateTimeFormat("short", time)
}
+// AbsoluteShort renders in "Sun, 01 Jan, 2006" format
+func (du *DateUtils) AbsoluteShortWithDay(time any) template.HTML {
+ return dateTimeFormat("short-with-day", time)
+}
+
// AbsoluteLong renders in "January 01, 2006" format
func (du *DateUtils) AbsoluteLong(time any) template.HTML {
return dateTimeFormat("long", time)
@@ -114,6 +119,10 @@ func dateTimeFormat(format string, datetime any) template.HTML {
case "short", "long": // date only
attrs = append(attrs, `month="`+format+`"`, `day="numeric"`)
return template.HTML(fmt.Sprintf(`88fc37a3c0...12fc37a3c0 (hash)
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
-88fc37a3c0
+88fc37a3c0
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
👍
mail@domain.com
@@ -125,7 +125,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
}
func TestRenderCommitMessage(t *testing.T) {
- expected := `space @mention-user `
+ expected := `space @mention-user`
assert.EqualValues(t, expected, RenderCommitMessage(t.Context(), testInput, testMetas))
}
@@ -137,7 +137,7 @@ func TestRenderCommitMessageLinkSubject(t *testing.T) {
}
func TestRenderIssueTitle(t *testing.T) {
- expected := ` space @mention-user
+ expected := ` space @mention-user
/just/a/path.bin
https://example.com/file.bin
[local link](file.bin)
@@ -163,7 +163,7 @@ mail@domain.com
}
func TestRenderRefIssueTitle(t *testing.T) {
- expected := ` space @mention-user
+ expected := ` space @mention-user
/just/a/path.bin
https://example.com/file.bin
[local link](file.bin)
@@ -189,7 +189,7 @@ mail@domain.com
}
func TestRenderMarkdownToHtml(t *testing.T) {
- expected := `
space @mention-user
+ expected := `
space @mention-user /just/a/path.bin https://example.com/file.bin local link diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 2c0a93f2ba..e77b1cb581 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -28,6 +28,21 @@