diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl
new file mode 100644
index 0000000000000..80823ea342aac
--- /dev/null
+++ b/templates/repo/commit_author.tmpl
@@ -0,0 +1,56 @@
+{{/* Template Attributes:
+* 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
+*/}}
+
+ {{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}}
+ {{$username := ""}}
+ {{if and .Author.FullName DefaultShowFullName}}
+ {{$username = .Author.FullName}}
+ {{else if .Author.Name}}
+ {{$username = .Author.Name}}
+ {{else if .Commit.Author.Name}}
+ {{$username = .Commit.Author.Name}}
+ {{end}}
+ {{ctx.AvatarUtils.AvatarByEmail .Author.Email $username .AvatarSize}}
+
+ {{if .Author.HomeLink}}
+
+ {{$username}}
+
+ {{else}}
+ {{$username}}
+ {{end}}
+
+ {{else}}
+ {{$username := ""}}
+ {{if .Commit.Author.Name}}
+ {{$username = .Commit.Author.Name}}
+ {{else}}
+ {{$username = .Author.Name}}
+ {{end}}
+ {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email $username .AvatarSize}}
+
+ {{if .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 68ccf9d275f4a..97b3e51ba9f3f 100644
--- a/templates/repo/commit_page.tmpl
+++ b/templates/repo/commit_page.tmpl
@@ -128,19 +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
+ "Commit" .Commit
+ "Author" .Author
+ "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 959f2a9398575..e1d8141ab9fc6 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.Name 28 "tw-mr-2"}}
- {{$userName}}
- {{end}}
+ {{template "repo/commit_author" (dict
+ "Commit" .
+ "User" .User
+ "AvatarSize" 28
+ "IsSigned" $.IsSigned
+ )}}
|
diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl
index cff338949f219..f2fa5c1b89658 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
+ "Commit" .LatestCommit
+ "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}}
|