Drop instaweb support

I had been considering extracting it, but it's so badly broken that
clearly nobody actually uses it.
This commit is contained in:
Tim Pope 2018-07-22 16:59:44 -04:00
parent c938737960
commit e0b770a9bd
2 changed files with 15 additions and 87 deletions

View File

@ -2560,8 +2560,7 @@ function! s:Browse(bang,line1,count,...) abort
endif endif
endif endif
for Handler in g:fugitive_browse_handlers let opts = {
let url = call(Handler, [{
\ 'dir': b:git_dir, \ 'dir': b:git_dir,
\ 'repo': s:repo(), \ 'repo': s:repo(),
\ 'remote': raw, \ 'remote': raw,
@ -2570,16 +2569,17 @@ function! s:Browse(bang,line1,count,...) abort
\ 'path': path, \ 'path': path,
\ 'type': type, \ 'type': type,
\ 'line1': a:count > 0 ? a:line1 : 0, \ 'line1': a:count > 0 ? a:line1 : 0,
\ 'line2': a:count > 0 ? a:count : 0}]) \ 'line2': a:count > 0 ? a:count : 0}
for Handler in get(g:, 'fugitive_browse_handlers', [])
let url = call(Handler, [copy(opts)])
if !empty(url) if !empty(url)
break break
endif endif
endfor endfor
if empty(url) && raw ==# '.' if empty(url)
call s:throw("Instaweb failed to start") call s:throw("No Gbrowse handler found for '".raw."'")
elseif empty(url)
call s:throw("'".remote."' is not a supported remote")
endif endif
let url = s:gsub(url, '[ <>]', '\="%".printf("%02X",char2nr(submatch(0)))') let url = s:gsub(url, '[ <>]', '\="%".printf("%02X",char2nr(submatch(0)))')
@ -2605,72 +2605,6 @@ function! s:Browse(bang,line1,count,...) abort
endtry endtry
endfunction endfunction
function! s:github_url(opts, ...) abort
if a:0 || type(a:opts) != type({})
return ''
endif
let domain_pattern = 'github\.com'
let domains = exists('g:fugitive_github_domains') ? g:fugitive_github_domains : []
for domain in domains
let domain_pattern .= '\|' . escape(split(domain, '://')[-1], '.')
endfor
let repo = matchstr(get(a:opts, 'remote'), '^\%(https\=://\|git://\|git@\)\=\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=$')
if repo ==# ''
return ''
endif
call s:warn('Install rhubarb.vim for GitHub support')
return 'https://github.com/tpope/vim-rhubarb'
endfunction
function! s:instaweb_url(opts) abort
if a:opts.remote !=# '.'
return ''
endif
let output = system(get(g:, 'fugitive_executable', 'git') . ' --git-dir=' . shellescape(a:opts.dir) . ' instaweb -b unknown')
if output =~# 'http://'
let root = matchstr(output,"http://[^\n]*").'/?p='.fnamemodify(a:opts.dir, ':t')
else
return ''
endif
if a:opts.path =~# '^\.git/refs/.'
return root . ';a=shortlog;h=' . matchstr(a:opts.path,'^\.git/\zs.*')
elseif a:opts.path =~# '^\.git\>'
return root
endif
let url = root
if a:opts.commit =~# '^\x\{40\}$'
if a:opts.type ==# 'commit'
let url .= ';a=commit'
endif
let url .= ';h=' . a:opts.repo.rev_parse(a:opts.commit . (a:opts.path == '' ? '' : ':' . a:opts.path))
else
if a:opts.type ==# 'blob' && empty(a:opts.commit)
let url .= ';h='.a:opts.repo.git_chomp('hash-object', '-w', a:opts.path)
else
try
let url .= ';h=' . a:opts.repo.rev_parse((a:opts.commit == '' ? 'HEAD' : ':' . a:opts.commit) . ':' . a:opts.path)
catch /^fugitive:/
call s:throw('fugitive: cannot browse uncommitted file')
endtry
endif
let root .= ';hb=' . a:opts.repo.head(-1)
endif
if a:opts.path !=# ''
let url .= ';f=' . a:opts.path
endif
if get(a:opts, 'line1')
let url .= '#l' . a:opts.line1
endif
return url
endfunction
if !exists('g:fugitive_browse_handlers')
let g:fugitive_browse_handlers = []
endif
call extend(g:fugitive_browse_handlers,
\ [s:function('s:github_url'), s:function('s:instaweb_url')])
" Section: File access " Section: File access
function! s:TempCmd(out, cmd, ...) abort function! s:TempCmd(out, cmd, ...) abort

View File

@ -251,12 +251,6 @@ that are part of Git repositories).
supported by installing rhubarb.vim, available at supported by installing rhubarb.vim, available at
<https://github.com/tpope/vim-rhubarb>. <https://github.com/tpope/vim-rhubarb>.
The hosting provider is determined by looking at the
remote for the current or specified branch and falls
back to "origin". In the special case of a "."
remote, a local instance of git-instaweb will be
started and used.
:Gbrowse {revision} Like :Gbrowse, but for a given |fugitive-revision|. A :Gbrowse {revision} Like :Gbrowse, but for a given |fugitive-revision|. A
useful value here is -, which ties the URL to the useful value here is -, which ties the URL to the
latest commit rather than a volatile branch. latest commit rather than a volatile branch.