-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Improve and unify commit author rendering #36094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8a27f2b
0809e97
8c78ba8
1ec7498
d714d2e
b14c757
8e1e53a
0cde670
c1bbb6b
2a9caf1
bcfd01d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| */}} | ||
| <div class="flex-text-inline{{if .AuthorBold}} tw-font-semibold{{end}}"> | ||
| {{if .User}} | ||
| {{ctx.AvatarUtils.Avatar .User .AvatarSize}} | ||
| {{$username := ""}} | ||
| {{if and .User.FullName DefaultShowFullName}} | ||
| {{$username = .User.FullName}} | ||
| {{else if .User.Name}} | ||
| {{$username = .User.Name}} | ||
| {{end}} | ||
|
Comment on lines
+13
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No. More complicated. |
||
| <a class="muted author-wrapper" href="{{.User.HomeLink}}" data-tooltip-content="{{$username}}"> | ||
| {{$username}} | ||
| </a> | ||
| {{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}} | ||
| <span{{if .IsSigned}} title="{{.Author.Email}}"{{end}}> | ||
| {{if .Author.HomeLink}} | ||
| <a class="muted author-wrapper" href="{{.Author.HomeLink}}"> | ||
| {{$username}} | ||
| </a> | ||
| {{else}} | ||
| {{$username}} | ||
| {{end}} | ||
| </span> | ||
| {{else}} | ||
| {{$username := ""}} | ||
| {{if .Commit.Author.Name}} | ||
| {{$username = .Commit.Author.Name}} | ||
| {{else}} | ||
| {{$username = .Author.Name}} | ||
| {{end}} | ||
| {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email $username .AvatarSize}} | ||
| <span{{if .IsSigned}} title="{{.Commit.Author.Email}}"{{end}}> | ||
| {{if .Commit.Author.Name}} | ||
| {{.Commit.Author.Name}} | ||
| {{else}} | ||
| {{.Author.Name}} | ||
| {{end}} | ||
| </span> | ||
| {{end}} | ||
| </div> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,20 +2,13 @@ | |
| {{if not .LatestCommit}} | ||
| … | ||
| {{else}} | ||
| {{if .LatestCommitUser}} | ||
| {{ctx.AvatarUtils.Avatar .LatestCommitUser 24}} | ||
| {{if and .LatestCommitUser.FullName DefaultShowFullName}} | ||
| <a class="muted author-wrapper" title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a> | ||
| {{else}} | ||
| <a class="muted author-wrapper" title="{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a> | ||
| {{end}} | ||
| {{else}} | ||
| {{if .LatestCommit.Author}} | ||
| {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}} | ||
| <span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span> | ||
| {{end}} | ||
| {{end}} | ||
|
|
||
| {{template "repo/commit_author" (dict | ||
| "User" .LatestCommitUser | ||
| "Commit" .LatestCommit | ||
| "AvatarSize" 24 | ||
| "AuthorBold" true | ||
| "IsSigned" $.IsSigned | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to pass "IsSigned" Use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, didn't know that existed. |
||
| )}} | ||
| {{template "repo/commit_sign_badge" dict "Commit" .LatestCommit "CommitBaseLink" (print .RepoLink "/commit") "CommitSignVerification" .LatestCommitVerification}} | ||
|
|
||
| {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should pass so many different structs.
Commitis not really used. What you need is a "git user" or "gitea user".Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit is used for
.Commit.Authorvs.Author. Maybe it can be unified, not sure. The three pages all pass different context variables.