Change arity of browse API
It's debatable whether the repo object should be passed at all, so let's not commit to a positional parameter for it. References #445.
This commit is contained in:
parent
5aaa65736d
commit
24d4098ceb
@ -2176,7 +2176,8 @@ function! s:Browse(bang,line1,count,...) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
for Handler in g:fugitive_browse_handlers
|
for Handler in g:fugitive_browse_handlers
|
||||||
let url = call(Handler, [s:repo(), {
|
let url = call(Handler, [{
|
||||||
|
\ 'repo': s:repo(),
|
||||||
\ 'remote': raw,
|
\ 'remote': raw,
|
||||||
\ 'revision': rev,
|
\ 'revision': rev,
|
||||||
\ 'commit': commit,
|
\ 'commit': commit,
|
||||||
@ -2206,7 +2207,7 @@ function! s:Browse(bang,line1,count,...) abort
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:github_url(repo, opts, ...) abort
|
function! s:github_url(opts, ...) abort
|
||||||
if a:0 || type(a:opts) != type({})
|
if a:0 || type(a:opts) != type({})
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
@ -2226,7 +2227,7 @@ function! s:github_url(repo, opts, ...) abort
|
|||||||
let root = 'https://' . s:sub(repo,':','/')
|
let root = 'https://' . s:sub(repo,':','/')
|
||||||
endif
|
endif
|
||||||
if path =~# '^\.git/refs/heads/'
|
if path =~# '^\.git/refs/heads/'
|
||||||
let branch = a: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 ==# ''
|
||||||
return root . '/commits/' . path[16:-1]
|
return root . '/commits/' . path[16:-1]
|
||||||
else
|
else
|
||||||
@ -2242,8 +2243,8 @@ function! s:github_url(repo, opts, ...) abort
|
|||||||
if a:opts.revision =~# '^[[:alnum:]._-]\+:'
|
if a:opts.revision =~# '^[[:alnum:]._-]\+:'
|
||||||
let commit = matchstr(a:opts.revision,'^[^:]*')
|
let commit = matchstr(a:opts.revision,'^[^:]*')
|
||||||
elseif a:opts.commit =~# '^\d\=$'
|
elseif a:opts.commit =~# '^\d\=$'
|
||||||
let local = matchstr(a:repo.head_ref(),'\<refs/heads/\zs.*')
|
let local = matchstr(a:opts.repo.head_ref(),'\<refs/heads/\zs.*')
|
||||||
let commit = a:repo.git_chomp('config','branch.'.local.'.merge')[11:-1]
|
let commit = a:opts.repo.git_chomp('config','branch.'.local.'.merge')[11:-1]
|
||||||
if commit ==# ''
|
if commit ==# ''
|
||||||
let commit = local
|
let commit = local
|
||||||
endif
|
endif
|
||||||
@ -2268,10 +2269,10 @@ function! s:github_url(repo, opts, ...) abort
|
|||||||
return url
|
return url
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:instaweb_url(repo, opts) abort
|
function! s:instaweb_url(opts) abort
|
||||||
let output = a:repo.git_chomp('instaweb','-b','unknown')
|
let output = a:opts.repo.git_chomp('instaweb','-b','unknown')
|
||||||
if output =~# 'http://'
|
if output =~# 'http://'
|
||||||
let root = matchstr(output,'http://.*').'/?p='.fnamemodify(a:repo.dir(),':t')
|
let root = matchstr(output,'http://.*').'/?p='.fnamemodify(a:opts.repo.opts.dir(),':t')
|
||||||
else
|
else
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
@ -2285,20 +2286,20 @@ function! s:instaweb_url(repo, opts) abort
|
|||||||
if a:opts.type ==# 'commit'
|
if a:opts.type ==# 'commit'
|
||||||
let url .= ';a=commit'
|
let url .= ';a=commit'
|
||||||
endif
|
endif
|
||||||
let url .= ';h=' . a:repo.rev_parse(a:opts.commit . (a:opts.path == '' ? '' : ':' . a:opts.path))
|
let url .= ';h=' . a:opts.repo.rev_parse(a:opts.commit . (a:opts.path == '' ? '' : ':' . a:opts.path))
|
||||||
else
|
else
|
||||||
if a:opts.type ==# 'blob'
|
if a:opts.type ==# 'blob'
|
||||||
let tmp = tempname()
|
let tmp = tempname()
|
||||||
silent execute 'write !'.a:repo.git_command('hash-object','-w','--stdin').' > '.tmp
|
silent execute 'write !'.a:opts.repo.git_command('hash-object','-w','--stdin').' > '.tmp
|
||||||
let url .= ';h=' . readfile(tmp)[0]
|
let url .= ';h=' . readfile(tmp)[0]
|
||||||
else
|
else
|
||||||
try
|
try
|
||||||
let url .= ';h=' . a:repo.rev_parse((a:opts.commit == '' ? 'HEAD' : ':' . a:opts.commit) . ':' . a:opts.path)
|
let url .= ';h=' . a:opts.repo.rev_parse((a:opts.commit == '' ? 'HEAD' : ':' . a:opts.commit) . ':' . a:opts.path)
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
call s:throw('fugitive: cannot browse uncommitted file')
|
call s:throw('fugitive: cannot browse uncommitted file')
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
let root .= ';hb=' . matchstr(a:repo.head_ref(),'[^ ]\+$')
|
let root .= ';hb=' . matchstr(a:opts.repo.head_ref(),'[^ ]\+$')
|
||||||
endif
|
endif
|
||||||
if a:opts.path !=# ''
|
if a:opts.path !=# ''
|
||||||
let url .= ';f=' . a:opts.path
|
let url .= ';f=' . a:opts.path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user