Future proofing

This commit is contained in:
Tim Pope
2015-12-01 19:03:49 -05:00
parent ba6057c101
commit c6c6f4bbf3

View File

@@ -191,7 +191,7 @@ function! rhubarb#fugitive_url(opts, ...) abort
if empty(root) if empty(root)
return '' return ''
endif endif
let path = a:opts.path let path = substitute(a:opts.path, '^/', '', '')
if path =~# '^\.git/refs/heads/' if path =~# '^\.git/refs/heads/'
let branch = a:opts.repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1] let branch = a:opts.repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1]
if branch ==# '' if branch ==# ''
@@ -219,7 +219,7 @@ function! rhubarb#fugitive_url(opts, ...) abort
else else
let commit = a:opts.commit let commit = a:opts.commit
endif endif
if a:opts.type == 'tree' if get(a:opts, 'type', '') ==# 'tree' || a:opts.path =~# '/$'
let url = substitute(root . '/tree/' . commit . '/' . path, '/$', '', 'g') let url = substitute(root . '/tree/' . commit . '/' . path, '/$', '', 'g')
elseif a:opts.type == 'blob' elseif a:opts.type == 'blob'
let url = root . '/blob/' . commit . '/' . path let url = root . '/blob/' . commit . '/' . path