diff options
author | JakobDev <jakobdev@gmx.de> | 2024-01-15 17:42:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 17:42:15 +0100 |
commit | 885cc32b14584ee2d01009768895b7a776441504 (patch) | |
tree | 3eb87de74da708b35945d32e30443de2f649077c /templates | |
parent | 2c3da59e275b69ebf984bb70954f42a7bcb0b49d (diff) | |
download | gitea-885cc32b14584ee2d01009768895b7a776441504.tar.gz gitea-885cc32b14584ee2d01009768895b7a776441504.zip |
Show latest commit for file (#28067)
If you view a file, you can now see the latest commit that changed that file.
![grafik](https://github.com/go-gitea/gitea/assets/15185051/272c3120-6db7-4f88-86e1-60080c9aabe5)
---------
Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/repo/latest_commit.tmpl | 31 | ||||
-rw-r--r-- | templates/repo/view_file.tmpl | 16 | ||||
-rw-r--r-- | templates/repo/view_list.tmpl | 32 |
3 files changed, 48 insertions, 31 deletions
diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl new file mode 100644 index 0000000000..b2f0798917 --- /dev/null +++ b/templates/repo/latest_commit.tmpl @@ -0,0 +1,31 @@ +{{if not .LatestCommit}} + <div class="ui active tiny slow centered inline">…</div> +{{else}} + {{if .LatestCommitUser}} + {{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "gt-mr-2"}} + {{if .LatestCommitUser.FullName}} + <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 "gt-mr-2"}} + <span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span> + {{end}} + {{end}} + <a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified}} isVerified{{if eq .LatestCommitVerification.TrustStatus "trusted"}}{{else if eq .LatestCommitVerification.TrustStatus "untrusted"}}Untrusted{{else}}Unmatched{{end}}{{else if .LatestCommitVerification.Warning}} isWarning{{end}}{{end}}" href="{{.RepoLink}}/commit/{{PathEscape .LatestCommit.ID.String}}"> + <span class="shortsha">{{ShortSha .LatestCommit.ID.String}}</span> + {{if .LatestCommit.Signature}} + {{template "repo/shabox_badge" dict "root" $ "verification" .LatestCommitVerification}} + {{end}} + </a> + {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} + {{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}} + <span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $commitLink ($.Repository.ComposeMetas ctx)}}</span> + {{if IsMultilineCommitMessage .LatestCommit.Message}} + <button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button> + <pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .LatestCommit.Message ($.Repository.ComposeMetas ctx)}}</pre> + {{end}} + </span> +{{end}} diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index e7d1c04c12..e6591df7e3 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -9,6 +9,22 @@ <div class="text left gt-whitespace-pre">{{.FileWarning}}</div> </div> {{end}} + + {{if not .ReadmeInList}} + <div id="repo-file-commit-box" class="ui top attached header list-header gt-mb-4"> + <div> + {{template "repo/latest_commit" .}} + </div> + {{if .LatestCommit}} + {{if .LatestCommit.Committer}} + <div class="ui text grey right age"> + {{TimeSince .LatestCommit.Committer.When ctx.Locale}} + </div> + {{end}} + {{end}} + </div> + {{end}} + <h4 class="file-header ui top attached header gt-df gt-ac gt-sb gt-fw"> <div class="file-header-left gt-df gt-ac gt-py-3 gt-pr-4"> {{if .ReadmeInList}} diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 504032aa78..c1ef4ff4cb 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -2,37 +2,7 @@ <thead> <tr class="commit-list"> <th colspan="2" {{if not .LatestCommit}}class="notready"{{end}}> - {{if not .LatestCommit}} - <div class="ui active tiny slow centered inline">…</div> - {{else}} - {{if .LatestCommitUser}} - {{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "gt-mr-2"}} - {{if .LatestCommitUser.FullName}} - <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 "gt-mr-2"}} - <span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span> - {{end}} - {{end}} - <a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified}} isVerified{{if eq .LatestCommitVerification.TrustStatus "trusted"}}{{else if eq .LatestCommitVerification.TrustStatus "untrusted"}}Untrusted{{else}}Unmatched{{end}}{{else if .LatestCommitVerification.Warning}} isWarning{{end}}{{end}}" href="{{.RepoLink}}/commit/{{PathEscape .LatestCommit.ID.String}}"> - <span class="shortsha">{{ShortSha .LatestCommit.ID.String}}</span> - {{if .LatestCommit.Signature}} - {{template "repo/shabox_badge" dict "root" $ "verification" .LatestCommitVerification}} - {{end}} - </a> - {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} - {{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}} - <span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $commitLink ($.Repository.ComposeMetas ctx)}}</span> - {{if IsMultilineCommitMessage .LatestCommit.Message}} - <button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button> - <pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .LatestCommit.Message ($.Repository.ComposeMetas ctx)}}</pre> - {{end}} - </span> - {{end}} + {{template "repo/latest_commit" .}} </th> <th class="text grey right age">{{if .LatestCommit}}{{if .LatestCommit.Committer}}{{TimeSince .LatestCommit.Committer.When ctx.Locale}}{{end}}{{end}}</th> </tr> |