Skip to content

Add copy Commit ID button in commits list #17759

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

Merged
merged 11 commits into from
Nov 23, 2021
3 changes: 3 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,9 @@ commits.search.tooltip = You can prefix keywords with "author:", "committer:", "
commits.find = Search
commits.search_all = All Branches
commits.author = Author
commits.copy_sha_text = Copy
commits.copy_sha_success = Commit ID has been copied
commits.copy_sha_error = Use ⌘C or Ctrl-C to copy
commits.message = Message
commits.date = Date
commits.older = Older
Expand Down
11 changes: 11 additions & 0 deletions templates/repo/commits_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@
{{else}}
</span>
{{end}}
{{$commitID := .ID.String}}
<span class="clipboard"
data-success="{{$.i18n.Tr "repo.commits.copy_sha_success"}}"
data-error="{{$.i18n.Tr "repo.commits.copy_sha_error"}}"
data-content="{{$.i18n.Tr "repo.commits.copy_sha_text"}}"
data-variation="inverted tiny"
data-clipboard-text="{{.ID}}"
onclick="'{{$commitID}}'.select(); document.execCommand('copy');"
>
{{svg "octicon-paste"}}
</span>
</td>
<td class="message">
<span class="message-wrapper">
Expand Down