forked from ehamiter/Sublime-Text-2-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blame.py
18 lines (16 loc) · 844 Bytes
/
blame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import sublime
import sublime_plugin
class BlameCommand(sublime_plugin.TextCommand):
def run(self, edit):
if len(self.view.file_name()) > 0:
folder_name, file_name = os.path.split(self.view.file_name())
begin_line, begin_column = self.view.rowcol(self.view.sel()[0].begin())
end_line, end_column = self.view.rowcol(self.view.sel()[0].end())
begin_line = str(begin_line)
end_line = str(end_line)
lines = begin_line + ',' + end_line
self.view.window().run_command('exec', {'cmd': ['git', 'blame', '-L', lines, file_name], 'working_dir': folder_name})
sublime.status_message("git blame -L " + lines + " " + file_name)
def is_enabled(self):
return self.view.file_name() and len(self.view.file_name()) > 0