From e0b770a9bde9bd0084006fabca5b53e6591e3360 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 22 Jul 2018 16:59:44 -0400 Subject: [PATCH] Drop instaweb support I had been considering extracting it, but it's so badly broken that clearly nobody actually uses it. --- autoload/fugitive.vim | 96 +++++++------------------------------------ doc/fugitive.txt | 6 --- 2 files changed, 15 insertions(+), 87 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index d9f351f..a2ffd16 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2560,26 +2560,26 @@ function! s:Browse(bang,line1,count,...) abort endif endif - for Handler in g:fugitive_browse_handlers - let url = call(Handler, [{ - \ 'dir': b:git_dir, - \ 'repo': s:repo(), - \ 'remote': raw, - \ 'revision': 'No longer provided', - \ 'commit': commit, - \ 'path': path, - \ 'type': type, - \ 'line1': a:count > 0 ? a:line1 : 0, - \ 'line2': a:count > 0 ? a:count : 0}]) + let opts = { + \ 'dir': b:git_dir, + \ 'repo': s:repo(), + \ 'remote': raw, + \ 'revision': 'No longer provided', + \ 'commit': commit, + \ 'path': path, + \ 'type': type, + \ 'line1': a:count > 0 ? a:line1 : 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) break endif endfor - if empty(url) && raw ==# '.' - call s:throw("Instaweb failed to start") - elseif empty(url) - call s:throw("'".remote."' is not a supported remote") + if empty(url) + call s:throw("No Gbrowse handler found for '".raw."'") endif let url = s:gsub(url, '[ <>]', '\="%".printf("%02X",char2nr(submatch(0)))') @@ -2605,72 +2605,6 @@ function! s:Browse(bang,line1,count,...) abort endtry 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 function! s:TempCmd(out, cmd, ...) abort diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 2e06d37..df9cb5f 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -251,12 +251,6 @@ that are part of Git repositories). supported by installing rhubarb.vim, available at . - 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 useful value here is -, which ties the URL to the latest commit rather than a volatile branch.