Skip to content

Commit

Permalink
blame on github
Browse files Browse the repository at this point in the history
  • Loading branch information
buhrmi committed Oct 2, 2012
1 parent c1cbc12 commit 9479b0b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[
{ "keys": ["super+\\"], "command": "githubify"}
{ "keys": ["super+\\"], "command": "githubify"},
{ "keys": ["shift+super+\\"], "command": "githubify_blame"}
]
6 changes: 5 additions & 1 deletion Githubify.sublime-commands
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[
{
"caption": "View File on Github"
, "command": "view_on_github"
, "command": "githubify"
},
{
"caption": "Blame File on Github"
, "command": "githubify_blame"
}
]
22 changes: 19 additions & 3 deletions GithubifyCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import os


class GithubifyCommand(sublime_plugin.TextCommand):

class Githubify(sublime_plugin.TextCommand):
def check_output(self, command, cwd):
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, cwd=cwd)
output, unused_err = process.communicate()
Expand All @@ -18,7 +17,7 @@ def check_output(self, command, cwd):
raise error
return output

def run(self, edit):
def gather_info(self, edit):
absfile = self.view.file_name()

if absfile == None:
Expand All @@ -38,7 +37,24 @@ def run(self, edit):
else:
lines = '%s-%s' % (begin_line, end_line)

return github_repo, branch, relfile, lines


class GithubifyCommand(Githubify):
def run(self, edit):
github_repo, branch, relfile, lines = self.gather_info(edit)

url = 'https://github.com/%s/blob/%s/%s#L%s' % \
(github_repo, branch, relfile, lines)

self.view.window().run_command('open_url', {"url": url})


class GithubifyBlameCommand(Githubify):
def run(self, edit):
github_repo, branch, relfile, lines = self.gather_info(edit)

url = 'https://github.com/%s/blame/%s/%s#L%s' % \
(github_repo, branch, relfile, lines)

self.view.window().run_command('open_url', {"url": url})
Binary file modified GithubifyCommand.pyc
Binary file not shown.

0 comments on commit 9479b0b

Please sign in to comment.