From b2b49c9bde63b311f01d500ada9212c46b9602fe Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 6 Apr 2024 02:03:07 +0800 Subject: [PATCH] Fix view commit link (#30297) Fix #30098 --- templates/repo/commits_list.tmpl | 173 +++++++++++++++---------------- 1 file changed, 86 insertions(+), 87 deletions(-) diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 53052333fa..be73c4ca18 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -1,92 +1,91 @@
- - +
+ + + + + + + + + + + {{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}} + {{range .Commits}} - - - - - - - - - {{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}} - {{range .Commits}} - - - - - {{if .Committer}} - + {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}{{$userName}} {{else}} - + {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}} + {{$userName}} {{end}} - - - {{end}} - -
{{ctx.Locale.Tr "repo.commits.author"}}{{StringUtils.ToUpper $.Repository.ObjectFormatName}}{{ctx.Locale.Tr "repo.commits.message"}}{{ctx.Locale.Tr "repo.commits.date"}}
{{ctx.Locale.Tr "repo.commits.author"}}{{StringUtils.ToUpper $.Repository.ObjectFormatName}}{{ctx.Locale.Tr "repo.commits.message"}}{{ctx.Locale.Tr "repo.commits.date"}}
- {{$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}} + + {{$userName := .Author.Name}} + {{if .User}} + {{if and .User.FullName DefaultShowFullName}} + {{$userName = .User.FullName}} {{end}} - - {{$class := "ui sha label"}} - {{if .Signature}} - {{$class = (print $class " isSigned")}} - {{if .Verification.Verified}} - {{if eq .Verification.TrustStatus "trusted"}} - {{$class = (print $class " isVerified")}} - {{else if eq .Verification.TrustStatus "untrusted"}} - {{$class = (print $class " isVerifiedUntrusted")}} - {{else}} - {{$class = (print $class " isVerifiedUnmatched")}} - {{end}} - {{else if .Verification.Warning}} - {{$class = (print $class " isWarning")}} - {{end}} - {{end}} - {{$commitShaLink := ""}} - {{if $.PageIsWiki}} - {{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}} - {{else if $.PageIsPullCommits}} - {{$commitShaLink = (printf "%s/pulls/%d/commits/%s" $commitRepoLink $.Issue.Index (PathEscape .ID.String))}} - {{else if $.Reponame}} - {{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}} - {{end}} - - {{ShortSha .ID.String}} - {{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}} - - - - {{if $.PageIsWiki}} - {{.Summary | RenderEmoji $.Context}} - {{else}} - {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} - {{RenderCommitMessageLinkSubject $.Context .Message $commitLink ($.Repository.ComposeMetas ctx)}} - {{end}} - - {{if IsMultilineCommitMessage .Message}} - - {{end}} - {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} - {{if IsMultilineCommitMessage .Message}} -
{{RenderCommitBody $.Context .Message ($.Repository.ComposeMetas ctx)}}
- {{end}} -
{{TimeSince .Committer.When ctx.Locale}}{{TimeSince .Author.When ctx.Locale}} - - - {{svg "octicon-file-code"}} - -
-
+ + + {{$class := "ui sha label"}} + {{if .Signature}} + {{$class = (print $class " isSigned")}} + {{if .Verification.Verified}} + {{if eq .Verification.TrustStatus "trusted"}} + {{$class = (print $class " isVerified")}} + {{else if eq .Verification.TrustStatus "untrusted"}} + {{$class = (print $class " isVerifiedUntrusted")}} + {{else}} + {{$class = (print $class " isVerifiedUnmatched")}} + {{end}} + {{else if .Verification.Warning}} + {{$class = (print $class " isWarning")}} + {{end}} + {{end}} + {{$commitShaLink := ""}} + {{if $.PageIsWiki}} + {{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}} + {{else if $.PageIsPullCommits}} + {{$commitShaLink = (printf "%s/pulls/%d/commits/%s" $commitRepoLink $.Issue.Index (PathEscape .ID.String))}} + {{else if $.Reponame}} + {{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}} + {{end}} + + {{ShortSha .ID.String}} + {{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}} + + + + + {{if $.PageIsWiki}} + {{.Summary | RenderEmoji $.Context}} + {{else}} + {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} + {{RenderCommitMessageLinkSubject $.Context .Message $commitLink ($.Repository.ComposeMetas ctx)}} + {{end}} + + {{if IsMultilineCommitMessage .Message}} + + {{end}} + {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} + {{if IsMultilineCommitMessage .Message}} +
{{RenderCommitBody $.Context .Message ($.Repository.ComposeMetas ctx)}}
+ {{end}} + + {{if .Committer}} + {{TimeSince .Committer.When ctx.Locale}} + {{else}} + {{TimeSince .Author.When ctx.Locale}} + {{end}} + + + {{if not $.PageIsWiki}}{{/* at the moment, wiki doesn't support "view at history point*/}} + {{$viewCommitLink := printf "%s/src/commit/%s" $commitRepoLink (PathEscape .ID.String)}} + {{if $.FileName}}{{$viewCommitLink = printf "%s/%s" $viewCommitLink (PathEscapeSegments $.FileName)}}{{end}} + {{svg "octicon-file-code"}} + {{end}} + + + {{end}} + + +