Skip to content

Commit 8fa57c4

Browse files
authored
Merge pull request #4 from psykzz/copy-sha
Clicking sha now copies
2 parents 7ffe532 + 4db6266 commit 8fa57c4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

git-blame.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
text-decoration: none;
1818
}}
1919
</style>
20-
<a href="close">
2120
<strong>Git Blame:</strong> ({user})
22-
Last updated: {date} {time} | [{sha}]
21+
Updated: {date} {time} |
22+
<a href="copy-{sha}">[{sha}]</a> |
23+
<a href="close">
2324
<close>X</close>&nbsp;
2425
</a>
2526
</span>
@@ -56,9 +57,20 @@ def parse_blame(self, blame):
5657
user, date, time, tz_offset = file_path, user, date, time
5758
file_path = None
5859

60+
# Fix an issue where the username has a space
61+
# Im going to need to do something better though if people
62+
# start to have multiple spaces in their names.
63+
if not isinstance(date[0], int):
64+
user = "{0} {1}".format(user, date)
65+
date, time = time, tz_offset
66+
5967
return(sha, user[1:], date, time)
6068

6169
def on_phantom_close(self, href):
70+
if href.startswith('copy'):
71+
sha = href.replace('copy-','')
72+
sublime.set_clipboard(sha)
73+
6274
self.view.erase_phantoms('git-blame')
6375

6476

0 commit comments

Comments
 (0)