From 8a27f2be403afe15dad4cf98f23bceb989311e2e Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 5 Dec 2025 09:43:23 +0100 Subject: [PATCH 01/14] Improve and unify anonymous user e-mail display --- templates/repo/commit_page.tmpl | 13 ++++++++----- templates/repo/commits_list.tmpl | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 68ccf9d275f4a..aabfed35b3543 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -128,19 +128,22 @@
-
- {{if .Author}} + {{if .Author}} +
{{ctx.AvatarUtils.Avatar .Author 20}} {{if .Author.FullName}} {{.Author.FullName}} {{else}} {{.Commit.Author.Name}} {{end}} - {{else}} +
+ {{else}} +
{{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 20}} {{.Commit.Author.Name}} - {{end}} -
+
+ {{end}} + {{DateUtils.TimeSince .Commit.Author.When}} diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 959f2a9398575..c38eaf90362fb 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -22,8 +22,8 @@ {{end}} {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}{{$userName}} {{else}} - {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}} - {{$userName}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Email 28 "tw-mr-2"}} + {{$userName}} {{end}}
From 0809e97bb27ed7a36e1dbb1d29f95aaed6be5a1b Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 5 Dec 2025 09:47:11 +0100 Subject: [PATCH 02/14] add to latest --- templates/repo/latest_commit.tmpl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl index cff338949f219..a001b5ca4724a 100644 --- a/templates/repo/latest_commit.tmpl +++ b/templates/repo/latest_commit.tmpl @@ -12,7 +12,9 @@ {{else}} {{if .LatestCommit.Author}} {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}} - {{.LatestCommit.Author.Name}} + + {{.LatestCommit.Author.Name}} + {{end}} {{end}} From 8c78ba8b43da588b02a02c103db55f238537ea8b Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 5 Dec 2025 09:49:13 +0100 Subject: [PATCH 03/14] revert whitespace --- templates/repo/latest_commit.tmpl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl index a001b5ca4724a..a5a8820acdda1 100644 --- a/templates/repo/latest_commit.tmpl +++ b/templates/repo/latest_commit.tmpl @@ -12,9 +12,7 @@ {{else}} {{if .LatestCommit.Author}} {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}} - - {{.LatestCommit.Author.Name}} - + {{.LatestCommit.Author.Name}} {{end}} {{end}} From 1ec7498c6aaade3b44ed379ebcc71ddde1ce8ac0 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 5 Dec 2025 09:49:52 +0100 Subject: [PATCH 04/14] fix --- templates/repo/latest_commit.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl index a5a8820acdda1..e328b48e844c5 100644 --- a/templates/repo/latest_commit.tmpl +++ b/templates/repo/latest_commit.tmpl @@ -12,7 +12,7 @@ {{else}} {{if .LatestCommit.Author}} {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}} - {{.LatestCommit.Author.Name}} + {{.LatestCommit.Author.Name}} {{end}} {{end}} From d714d2ec0fdfe8b77a4143a01e0c5c9c36ae8661 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 5 Dec 2025 10:25:29 +0100 Subject: [PATCH 05/14] restart ci From b14c757a819f2641e18568032bbc997756752ba8 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 5 Dec 2025 10:50:01 +0100 Subject: [PATCH 06/14] lint --- templates/repo/commit_page.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index aabfed35b3543..796566017ecbb 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -144,7 +144,6 @@ {{end}} - {{DateUtils.TimeSince .Commit.Author.When}}
From 0cde670b4ad2f36b93c6edd7d1668c23248add32 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 11 Dec 2025 02:28:22 +0100 Subject: [PATCH 07/14] wip --- templates/repo/commit_author.tmpl | 58 +++++++++++++++++++++++++++++++ templates/repo/commit_page.tmpl | 22 ++++-------- templates/repo/commits_list.tmpl | 16 ++++----- templates/repo/latest_commit.tmpl | 21 ++++------- 4 files changed, 78 insertions(+), 39 deletions(-) create mode 100644 templates/repo/commit_author.tmpl diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl new file mode 100644 index 0000000000000..ec7fb563cb059 --- /dev/null +++ b/templates/repo/commit_author.tmpl @@ -0,0 +1,58 @@ +{{/* Template Attributes: +* User: The user associated with the commit +* Author: The author associated with the commit +* Commit: The author associated with the commit +* AvatarSize: Avatar size in pixels +* AuthorBold: Whether to render the autor as bold text +* IsSigned: Whether the user is currently signed in +* Hack: Hack to avoid error related to .Author.FullName and .Author.HomeLink +*/}} +
+ {{if .User}} + {{ctx.AvatarUtils.Avatar .User .AvatarSize}} + {{$username := ""}} + {{if and .User.FullName DefaultShowFullName}} + {{$username = .User.FullName}} + {{else if .User.Name}} + {{$username = .User.Name}} + {{end}} + + {{$username}} + + {{else if .Author}} + b + {{$username := ""}} + {{if and .Author .Author.FullName DefaultShowFullName}} + {{$username = .Author.FullName}} + {{else if .Author.Name}} + {{$username = .Author.Name}} + {{else if and .Commit .Commit.Author .Commit.Author.Name}} + {{$username = .Commit.Author.Name}} + {{end}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email $username .AvatarSize}} + + {{if and .Hack .Author.HomeLink}} + + {{$username}} + + {{else}} + {{$username}} + {{end}} + + {{else}} + {{$username := ""}} + {{if and .Commit .Commit.Author .Commit.Author.Name}} + {{$username = .Commit.Author.Name}} + {{else}} + {{$username = .Author.Name}} + {{end}} + {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email $username .AvatarSize}} + + {{if and .Commit .Commit.Author .Commit.Author.Name}} + {{.Commit.Author.Name}} + {{else}} + {{.Author.Name}} + {{end}} + + {{end}} +
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 796566017ecbb..60316b8ac47f8 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -128,21 +128,13 @@
- {{if .Author}} -
- {{ctx.AvatarUtils.Avatar .Author 20}} - {{if .Author.FullName}} - {{.Author.FullName}} - {{else}} - {{.Commit.Author.Name}} - {{end}} -
- {{else}} -
- {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 20}} - {{.Commit.Author.Name}} -
- {{end}} + {{template "repo/commit_author" (dict + "Author" .Author + "Commit" .Commit + "AvatarSize" 20 + "AuthorBold" true + "IsSigned" $.IsSigned + )}} {{DateUtils.TimeSince .Commit.Author.When}} diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index c38eaf90362fb..43b924f70dfed 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -15,16 +15,12 @@
- {{$userName := .Author.Name}} - {{if .User}} - {{if and .User.FullName DefaultShowFullName}} - {{$userName = .User.FullName}} - {{end}} - {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}{{$userName}} - {{else}} - {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Email 28 "tw-mr-2"}} - {{$userName}} - {{end}} + {{template "repo/commit_author" (dict + "User" .User + "Author" .Author + "AvatarSize" 28 + "IsSigned" $.IsSigned + )}}
diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl index e328b48e844c5..4b09629a32bfb 100644 --- a/templates/repo/latest_commit.tmpl +++ b/templates/repo/latest_commit.tmpl @@ -2,20 +2,13 @@ {{if not .LatestCommit}} … {{else}} - {{if .LatestCommitUser}} - {{ctx.AvatarUtils.Avatar .LatestCommitUser 24}} - {{if and .LatestCommitUser.FullName DefaultShowFullName}} - {{.LatestCommitUser.FullName}} - {{else}} - {{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}} - {{end}} - {{else}} - {{if .LatestCommit.Author}} - {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}} - {{.LatestCommit.Author.Name}} - {{end}} - {{end}} - + {{template "repo/commit_author" (dict + "User" .LatestCommitUser + "Author" .LatestCommit.Author + "AvatarSize" 24 + "AuthorBold" true + "IsSigned" $.IsSigned + )}} {{template "repo/commit_sign_badge" dict "Commit" .LatestCommit "CommitBaseLink" (print .RepoLink "/commit") "CommitSignVerification" .LatestCommitVerification}} {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} From c1bbb6b74cd1eabb0ce637bbd3902e9f8d4da6c7 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 11 Dec 2025 02:33:50 +0100 Subject: [PATCH 08/14] clean up --- templates/repo/commit_author.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl index ec7fb563cb059..c0572f9b3d349 100644 --- a/templates/repo/commit_author.tmpl +++ b/templates/repo/commit_author.tmpl @@ -5,7 +5,6 @@ * AvatarSize: Avatar size in pixels * AuthorBold: Whether to render the autor as bold text * IsSigned: Whether the user is currently signed in -* Hack: Hack to avoid error related to .Author.FullName and .Author.HomeLink */}}
{{if .User}} From 2a9caf1d2cdc1a0aa2686300fe3953c4a18dd1dc Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 11 Dec 2025 02:48:26 +0100 Subject: [PATCH 09/14] don't pass .Author where it is invalid --- templates/repo/commit_author.tmpl | 6 +++--- templates/repo/commit_page.tmpl | 2 +- templates/repo/commits_list.tmpl | 2 +- templates/repo/latest_commit.tmpl | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl index c0572f9b3d349..b08323840f7b0 100644 --- a/templates/repo/commit_author.tmpl +++ b/templates/repo/commit_author.tmpl @@ -1,7 +1,7 @@ {{/* Template Attributes: -* User: The user associated with the commit -* Author: The author associated with the commit -* Commit: The author associated with the commit +* User: The user associated with the commit, if any +* Commit: The commit +* Author: The author, currently only the commit page passes this * AvatarSize: Avatar size in pixels * AuthorBold: Whether to render the autor as bold text * IsSigned: Whether the user is currently signed in diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 60316b8ac47f8..97b3e51ba9f3f 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -129,8 +129,8 @@
{{template "repo/commit_author" (dict - "Author" .Author "Commit" .Commit + "Author" .Author "AvatarSize" 20 "AuthorBold" true "IsSigned" $.IsSigned diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 43b924f70dfed..e1d8141ab9fc6 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -16,8 +16,8 @@
{{template "repo/commit_author" (dict + "Commit" . "User" .User - "Author" .Author "AvatarSize" 28 "IsSigned" $.IsSigned )}} diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl index 4b09629a32bfb..f2fa5c1b89658 100644 --- a/templates/repo/latest_commit.tmpl +++ b/templates/repo/latest_commit.tmpl @@ -4,7 +4,7 @@ {{else}} {{template "repo/commit_author" (dict "User" .LatestCommitUser - "Author" .LatestCommit.Author + "Commit" .LatestCommit "AvatarSize" 24 "AuthorBold" true "IsSigned" $.IsSigned From bcfd01dea7f253eab75d893b9e095c1bcc49df99 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 11 Dec 2025 02:54:56 +0100 Subject: [PATCH 10/14] cleanup --- templates/repo/commit_author.tmpl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl index b08323840f7b0..80823ea342aac 100644 --- a/templates/repo/commit_author.tmpl +++ b/templates/repo/commit_author.tmpl @@ -19,18 +19,17 @@ {{$username}} {{else if .Author}} - b {{$username := ""}} - {{if and .Author .Author.FullName DefaultShowFullName}} + {{if and .Author.FullName DefaultShowFullName}} {{$username = .Author.FullName}} {{else if .Author.Name}} {{$username = .Author.Name}} - {{else if and .Commit .Commit.Author .Commit.Author.Name}} + {{else if .Commit.Author.Name}} {{$username = .Commit.Author.Name}} {{end}} {{ctx.AvatarUtils.AvatarByEmail .Author.Email $username .AvatarSize}} - {{if and .Hack .Author.HomeLink}} + {{if .Author.HomeLink}} {{$username}} @@ -40,14 +39,14 @@ {{else}} {{$username := ""}} - {{if and .Commit .Commit.Author .Commit.Author.Name}} + {{if .Commit.Author.Name}} {{$username = .Commit.Author.Name}} {{else}} {{$username = .Author.Name}} {{end}} {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email $username .AvatarSize}} - {{if and .Commit .Commit.Author .Commit.Author.Name}} + {{if .Commit.Author.Name}} {{.Commit.Author.Name}} {{else}} {{.Author.Name}} From 108919d7a11f2885fe3e845fa7dbbb65e60b47c9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 13 Dec 2025 15:06:29 +0100 Subject: [PATCH 11/14] typo --- templates/repo/commit_author.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl index 80823ea342aac..349bcad853808 100644 --- a/templates/repo/commit_author.tmpl +++ b/templates/repo/commit_author.tmpl @@ -3,7 +3,7 @@ * Commit: The commit * Author: The author, currently only the commit page passes this * AvatarSize: Avatar size in pixels -* AuthorBold: Whether to render the autor as bold text +* AuthorBold: Whether to render the author as bold text * IsSigned: Whether the user is currently signed in */}}
From fd9a7a11bc64ef80531cd5cbcf79017446e8c9a3 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 13 Dec 2025 15:09:09 +0100 Subject: [PATCH 12/14] use ctx.RootData.IsSigned --- templates/repo/commit_author.tmpl | 5 ++--- templates/repo/commit_page.tmpl | 1 - templates/repo/commits_list.tmpl | 1 - templates/repo/latest_commit.tmpl | 1 - 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl index 349bcad853808..a767390a1f677 100644 --- a/templates/repo/commit_author.tmpl +++ b/templates/repo/commit_author.tmpl @@ -4,7 +4,6 @@ * Author: The author, currently only the commit page passes this * AvatarSize: Avatar size in pixels * AuthorBold: Whether to render the author as bold text -* IsSigned: Whether the user is currently signed in */}} diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl index f2fa5c1b89658..5b2bdfcb6e343 100644 --- a/templates/repo/latest_commit.tmpl +++ b/templates/repo/latest_commit.tmpl @@ -7,7 +7,6 @@ "Commit" .LatestCommit "AvatarSize" 24 "AuthorBold" true - "IsSigned" $.IsSigned )}} {{template "repo/commit_sign_badge" dict "Commit" .LatestCommit "CommitBaseLink" (print .RepoLink "/commit") "CommitSignVerification" .LatestCommitVerification}} From bebf59175a656ecbc862a34bdf1a3596574e95d5 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 13 Dec 2025 15:26:36 +0100 Subject: [PATCH 13/14] add author-wrapper class to fix integration --- templates/repo/commit_author.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl index a767390a1f677..4b96c55f3c51b 100644 --- a/templates/repo/commit_author.tmpl +++ b/templates/repo/commit_author.tmpl @@ -44,7 +44,7 @@ {{$username = .Author.Name}} {{end}} {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email $username .AvatarSize}} - + {{if .Commit.Author.Name}} {{.Commit.Author.Name}} {{else}} From e632d98bec4419fc517b5fcbc5d8326f9e2633e9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 13 Dec 2025 16:03:35 +0100 Subject: [PATCH 14/14] trim --- tests/integration/repo_commits_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/repo_commits_test.go b/tests/integration/repo_commits_test.go index b8f086e2b15ce..c611ecf3f48c0 100644 --- a/tests/integration/repo_commits_test.go +++ b/tests/integration/repo_commits_test.go @@ -8,6 +8,7 @@ import ( "net/http" "net/http/httptest" "path" + "strings" "sync" "testing" @@ -63,7 +64,7 @@ func TestRepoCommits(t *testing.T) { commitHref := doc.doc.Find("#commits-table tr:first-child .commit-id-short").AttrOr("href", "") assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref) authorElem := doc.doc.Find("#commits-table tr:first-child .author-wrapper") - assert.Equal(t, "6543", authorElem.Text()) + assert.Equal(t, "6543", strings.TrimSpace(authorElem.Text())) assert.Equal(t, "span", authorElem.Nodes[0].Data) }) @@ -74,7 +75,7 @@ func TestRepoCommits(t *testing.T) { commitHref := doc.doc.Find(".latest-commit .commit-id-short").AttrOr("href", "") assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref) authorElem := doc.doc.Find(".latest-commit .author-wrapper") - assert.Equal(t, "6543", authorElem.Text()) + assert.Equal(t, "6543", strings.TrimSpace(authorElem.Text())) assert.Equal(t, "span", authorElem.Nodes[0].Data) }) }