Skip to content

Commit b2b49c9

Browse files
authored
Fix view commit link (#30297)
Fix #30098
1 parent 556099f commit b2b49c9

File tree

1 file changed

+84
-85
lines changed

1 file changed

+84
-85
lines changed

templates/repo/commits_list.tmpl

Lines changed: 84 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,91 @@
11
<div class="ui attached table segment commit-table">
2-
<table class="ui very basic striped table unstackable" id="commits-table">
3-
<thead>
2+
<table class="ui very basic striped table unstackable" id="commits-table">
3+
<thead>
4+
<tr>
5+
<th class="three wide">{{ctx.Locale.Tr "repo.commits.author"}}</th>
6+
<th class="two wide sha">{{StringUtils.ToUpper $.Repository.ObjectFormatName}}</th>
7+
<th class="eight wide message">{{ctx.Locale.Tr "repo.commits.message"}}</th>
8+
<th class="two wide right aligned">{{ctx.Locale.Tr "repo.commits.date"}}</th>
9+
<th class="one wide"></th>
10+
</tr>
11+
</thead>
12+
<tbody class="commit-list">
13+
{{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}}
14+
{{range .Commits}}
415
<tr>
5-
<th class="three wide">{{ctx.Locale.Tr "repo.commits.author"}}</th>
6-
<th class="two wide sha">{{StringUtils.ToUpper $.Repository.ObjectFormatName}}</th>
7-
<th class="eight wide message">{{ctx.Locale.Tr "repo.commits.message"}}</th>
8-
<th class="two wide right aligned">{{ctx.Locale.Tr "repo.commits.date"}}</th>
9-
<th class="one wide"></th>
10-
</tr>
11-
</thead>
12-
<tbody class="commit-list">
13-
{{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}}
14-
{{range .Commits}}
15-
<tr>
16-
<td class="author tw-flex">
17-
{{$userName := .Author.Name}}
18-
{{if .User}}
19-
{{if and .User.FullName DefaultShowFullName}}
20-
{{$userName = .User.FullName}}
21-
{{end}}
22-
{{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}<a class="muted author-wrapper" href="{{.User.HomeLink}}">{{$userName}}</a>
23-
{{else}}
24-
{{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}}
25-
<span class="author-wrapper">{{$userName}}</span>
16+
<td class="author tw-flex">
17+
{{$userName := .Author.Name}}
18+
{{if .User}}
19+
{{if and .User.FullName DefaultShowFullName}}
20+
{{$userName = .User.FullName}}
2621
{{end}}
27-
</td>
28-
<td class="sha">
29-
{{$class := "ui sha label"}}
30-
{{if .Signature}}
31-
{{$class = (print $class " isSigned")}}
32-
{{if .Verification.Verified}}
33-
{{if eq .Verification.TrustStatus "trusted"}}
34-
{{$class = (print $class " isVerified")}}
35-
{{else if eq .Verification.TrustStatus "untrusted"}}
36-
{{$class = (print $class " isVerifiedUntrusted")}}
37-
{{else}}
38-
{{$class = (print $class " isVerifiedUnmatched")}}
39-
{{end}}
40-
{{else if .Verification.Warning}}
41-
{{$class = (print $class " isWarning")}}
22+
{{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}<a class="muted author-wrapper" href="{{.User.HomeLink}}">{{$userName}}</a>
23+
{{else}}
24+
{{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}}
25+
<span class="author-wrapper">{{$userName}}</span>
26+
{{end}}
27+
</td>
28+
<td class="sha">
29+
{{$class := "ui sha label"}}
30+
{{if .Signature}}
31+
{{$class = (print $class " isSigned")}}
32+
{{if .Verification.Verified}}
33+
{{if eq .Verification.TrustStatus "trusted"}}
34+
{{$class = (print $class " isVerified")}}
35+
{{else if eq .Verification.TrustStatus "untrusted"}}
36+
{{$class = (print $class " isVerifiedUntrusted")}}
37+
{{else}}
38+
{{$class = (print $class " isVerifiedUnmatched")}}
4239
{{end}}
40+
{{else if .Verification.Warning}}
41+
{{$class = (print $class " isWarning")}}
4342
{{end}}
44-
{{$commitShaLink := ""}}
45-
{{if $.PageIsWiki}}
46-
{{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}}
47-
{{else if $.PageIsPullCommits}}
48-
{{$commitShaLink = (printf "%s/pulls/%d/commits/%s" $commitRepoLink $.Issue.Index (PathEscape .ID.String))}}
49-
{{else if $.Reponame}}
50-
{{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}}
51-
{{end}}
52-
<a {{if $commitShaLink}}href="{{$commitShaLink}}"{{end}} class="{{$class}}">
53-
<span class="shortsha">{{ShortSha .ID.String}}</span>
54-
{{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}}
55-
</a>
56-
</td>
57-
<td class="message">
58-
<span class="message-wrapper">
59-
{{if $.PageIsWiki}}
60-
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary | RenderEmoji $.Context}}</span>
61-
{{else}}
62-
{{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}}
63-
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject $.Context .Message $commitLink ($.Repository.ComposeMetas ctx)}}</span>
64-
{{end}}
65-
</span>
66-
{{if IsMultilineCommitMessage .Message}}
67-
<button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button>
68-
{{end}}
69-
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}}
70-
{{if IsMultilineCommitMessage .Message}}
71-
<pre class="commit-body tw-hidden">{{RenderCommitBody $.Context .Message ($.Repository.ComposeMetas ctx)}}</pre>
72-
{{end}}
73-
</td>
74-
{{if .Committer}}
75-
<td class="text right aligned">{{TimeSince .Committer.When ctx.Locale}}</td>
43+
{{end}}
44+
{{$commitShaLink := ""}}
45+
{{if $.PageIsWiki}}
46+
{{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}}
47+
{{else if $.PageIsPullCommits}}
48+
{{$commitShaLink = (printf "%s/pulls/%d/commits/%s" $commitRepoLink $.Issue.Index (PathEscape .ID.String))}}
49+
{{else if $.Reponame}}
50+
{{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}}
51+
{{end}}
52+
<a {{if $commitShaLink}}href="{{$commitShaLink}}"{{end}} class="{{$class}}">
53+
<span class="shortsha">{{ShortSha .ID.String}}</span>
54+
{{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}}
55+
</a>
56+
</td>
57+
<td class="message">
58+
<span class="message-wrapper">
59+
{{if $.PageIsWiki}}
60+
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary | RenderEmoji $.Context}}</span>
7661
{{else}}
77-
<td class="text right aligned">{{TimeSince .Author.When ctx.Locale}}</td>
62+
{{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}}
63+
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject $.Context .Message $commitLink ($.Repository.ComposeMetas ctx)}}</span>
64+
{{end}}
65+
</span>
66+
{{if IsMultilineCommitMessage .Message}}
67+
<button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button>
7868
{{end}}
79-
<td class="text right aligned tw-py-0">
80-
<button class="btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button>
81-
<a
82-
class="btn interact-bg tw-p-2"
83-
data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}"
84-
href="{{if $.FileName}}{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) (PathEscapeSegments $.FileName)}}{{else}}{{printf "%s/src/commit/%s" $commitRepoLink (PathEscape .ID.String)}}{{end}}">
85-
{{svg "octicon-file-code"}}
86-
</a>
87-
</td>
88-
</tr>
89-
{{end}}
90-
</tbody>
91-
</table>
92-
</div>
69+
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}}
70+
{{if IsMultilineCommitMessage .Message}}
71+
<pre class="commit-body tw-hidden">{{RenderCommitBody $.Context .Message ($.Repository.ComposeMetas ctx)}}</pre>
72+
{{end}}
73+
</td>
74+
{{if .Committer}}
75+
<td class="text right aligned">{{TimeSince .Committer.When ctx.Locale}}</td>
76+
{{else}}
77+
<td class="text right aligned">{{TimeSince .Author.When ctx.Locale}}</td>
78+
{{end}}
79+
<td class="text right aligned tw-py-0">
80+
<button class="btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button>
81+
{{if not $.PageIsWiki}}{{/* at the moment, wiki doesn't support "view at history point*/}}
82+
{{$viewCommitLink := printf "%s/src/commit/%s" $commitRepoLink (PathEscape .ID.String)}}
83+
{{if $.FileName}}{{$viewCommitLink = printf "%s/%s" $viewCommitLink (PathEscapeSegments $.FileName)}}{{end}}
84+
<a class="btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}" href="{{$viewCommitLink}}">{{svg "octicon-file-code"}}</a>
85+
{{end}}
86+
</td>
87+
</tr>
88+
{{end}}
89+
</tbody>
90+
</table>
91+
</div>

0 commit comments

Comments
 (0)