Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions github.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,20 @@ def parse_heads(self, heads):
f = lambda l: tuple(re.split("\s", l.replace('refs/heads/', ''))[::-1])
return dict(map(f, heads.splitlines()))

def browse_file_url(self, filename):
def browse_file_url(self, filename, linenumber=False):
return git_browse_file_url(self.info['web_uri'],
self.path_from_rootdir(filename), self.branch)
self.path_from_rootdir(filename),
self.branch,
linenumber)

def file_history_url(self, filename):
return git_file_history_url(self.info['web_uri'],
self.path_from_rootdir(filename), self.branch)

def blame_file_url(self, filename):
def blame_file_url(self, filename, linenumber):
return git_blame_file_url(
self.info['web_uri'], self.path_from_rootdir(filename),
self.revision)
self.revision, linenumber)

def repository_url(self):
return git_repository_url(self.info['web_uri'])
Expand Down Expand Up @@ -257,14 +259,24 @@ def wrapper(self):
return wrapper


def git_browse_file_url(repository, filepath, branch='master'):
return "https://%s/blob/%s%s" % (repository, urllib.quote(branch), filepath)
def git_browse_file_url(repository, filepath, branch='master', linenumber=False):
return "https://%s/blob/%s%s%s" % (
repository,
urllib.quote(branch),
filepath,
"#L"+str(linenumber) if linenumber else '',
)

def git_file_history_url(repository, filepath, branch='master'):
return "https://%s/commits/%s%s" % (repository, branch, filepath)

def git_blame_file_url(repository, filepath, revision):
return "https://%s/blame/%s%s" % (repository, revision, filepath)
def git_blame_file_url(repository, filepath, revision, linenumber=False):
return "https://%s/blame/%s%s%s" % (
repository,
revision,
filepath,
"#L"+str(linenumber) if linenumber else '',
)


def git_issues_url(repository):
Expand Down
7 changes: 6 additions & 1 deletion github_blame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ class GithubBlameCommand(GithubWindowCommand):
@require_file
@with_repo
def run(self, repo):
open_url(repo.blame_file_url(self.relative_filename()))
open_url(
repo.blame_file_url(
self.relative_filename(),
self.current_line_number(),
)
)
7 changes: 6 additions & 1 deletion github_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ class GithubOpenCommand(GithubWindowCommand):
@require_file
@with_repo
def run(self, repo):
open_url(repo.browse_file_url(self.relative_filename()))
open_url(
repo.browse_file_url(
self.relative_filename(),
self.current_line_number(),
)
)