Skip to content

Commit 33de64c

Browse files
denyskonsilverwind
andauthored
link to file from its history (#27354)
Fixes #3852 Fixes #26707 Add a button on file history which directs you to the file at the selected commit. Co-authored-by: silverwind <[email protected]>
1 parent cb68e01 commit 33de64c

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ locked = Locked
9797

9898
copy = Copy
9999
copy_url = Copy URL
100+
copy_hash = Copy hash
100101
copy_content = Copy content
101102
copy_branch = Copy branch name
102103
copy_success = Copied!
@@ -1283,6 +1284,7 @@ commits.signed_by_untrusted_user = Signed by untrusted user
12831284
commits.signed_by_untrusted_user_unmatched = Signed by untrusted user who does not match committer
12841285
commits.gpg_key_id = GPG Key ID
12851286
commits.ssh_key_fingerprint = SSH Key Fingerprint
1287+
commits.view_path=View at this point in history
12861288
12871289
commit.operations = Operations
12881290
commit.revert = Revert

templates/repo/commits_list.tmpl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
<tr>
55
<th class="three wide">{{ctx.Locale.Tr "repo.commits.author"}}</th>
66
<th class="two wide sha">SHA1</th>
7-
<th class="nine wide message">{{ctx.Locale.Tr "repo.commits.message"}}</th>
7+
<th class="eight wide message">{{ctx.Locale.Tr "repo.commits.message"}}</th>
88
<th class="two wide right aligned">{{ctx.Locale.Tr "repo.commits.date"}}</th>
9+
<th class="one wide right aligned"></th>
910
</tr>
1011
</thead>
1112
<tbody class="commit-list">
@@ -25,7 +26,6 @@
2526
{{end}}
2627
</td>
2728
<td class="sha gt-df">
28-
<button class="ui button copy-commit-sha gt-df gt-ac" data-clipboard-text="{{.ID}}">{{svg "octicon-copy" 14}}</button>
2929
{{$class := "ui sha label"}}
3030
{{if .Signature}}
3131
{{$class = (print $class " isSigned")}}
@@ -76,6 +76,12 @@
7676
{{else}}
7777
<td class="text right aligned">{{TimeSince .Author.When ctx.Locale}}</td>
7878
{{end}}
79+
<td class="gt-pt-0 gt-pb-0">
80+
<div class="gt-df gt-je">
81+
<button class="btn interact-bg gt-p-3" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button>
82+
{{if $.FileName}}<a class="btn interact-bg gt-p-3" data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}" href="{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) $.FileName}}">{{svg "octicon-file-code"}}</a>{{end}}
83+
</div>
84+
</td>
7985
</tr>
8086
{{end}}
8187
</tbody>

web_src/css/base.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,13 +1328,6 @@ img.ui.avatar,
13281328
display: inline-block; /* not sure whether it is still needed */
13291329
}
13301330

1331-
.ui .button.copy-commit-sha {
1332-
border: 1px solid var(--color-light-border);
1333-
margin-right: 3px;
1334-
padding: 6px 6px 4px;
1335-
background: var(--color-light);
1336-
}
1337-
13381331
.ui .button.truncate {
13391332
display: inline-block;
13401333
max-width: 100%;

web_src/css/repo.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,9 +3051,6 @@ tbody.commit-list {
30513051
.commit-table th.sha {
30523052
display: none !important;
30533053
}
3054-
.commit-table .commit-list .copy-commit-sha {
3055-
display: none !important;
3056-
}
30573054
.comment-header {
30583055
flex-wrap: wrap;
30593056
}

0 commit comments

Comments
 (0)