mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-15 06:43:51 -05:00
DWIM for :GBrowse remote-name
Previously I had worried about the ambiguity this would produce, but that can be resolved by calling `:GBrowse remote-name/HEAD`.
This commit is contained in:
@@ -7224,7 +7224,7 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
|||||||
let remote = matchstr(arg, '^++\%([Gg]it\)\=[Rr]emote=\zs\S\+')
|
let remote = matchstr(arg, '^++\%([Gg]it\)\=[Rr]emote=\zs\S\+')
|
||||||
let arg = matchstr(arg, '\s\zs\S.*')
|
let arg = matchstr(arg, '\s\zs\S.*')
|
||||||
endif
|
endif
|
||||||
let validremote = '\.\%(git\)\=\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\='
|
let validremote = '\.\%(git\)\=\|\.\=/.*\|\a[[:alnum:]_-]*\%(://.\{-\}\)\='
|
||||||
if arg ==# '-'
|
if arg ==# '-'
|
||||||
let remote = ''
|
let remote = ''
|
||||||
let rev = ''
|
let rev = ''
|
||||||
@@ -7235,8 +7235,8 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
|||||||
return 'echoerr ' . string('fugitive: could not find prior :Git invocation')
|
return 'echoerr ' . string('fugitive: could not find prior :Git invocation')
|
||||||
endif
|
endif
|
||||||
elseif !exists('l:remote')
|
elseif !exists('l:remote')
|
||||||
let remote = matchstr(arg, '@\zs\%('.validremote.'\)$')
|
let remote = matchstr(arg, '\\\@<!\%(\\\\\)*[!@]\zs\%('.validremote.'\)$')
|
||||||
let rev = substitute(arg, '@\%('.validremote.'\)$','','')
|
let rev = strpart(arg, 0, len(arg) - len(remote) - (empty(remote) ? 0 : 1))
|
||||||
else
|
else
|
||||||
let rev = arg
|
let rev = arg
|
||||||
endif
|
endif
|
||||||
@@ -7257,6 +7257,11 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
|||||||
return 'echoerr ' . string('fugitive: no URL found in output of :Git')
|
return 'echoerr ' . string('fugitive: no URL found in output of :Git')
|
||||||
endif
|
endif
|
||||||
exe s:DirCheck(dir)
|
exe s:DirCheck(dir)
|
||||||
|
let config = fugitive#Config(dir)
|
||||||
|
if empty(remote) && expanded =~# '^[^-./:^~][^:^~]*$' && !empty(FugitiveConfigGet('remote.' . expanded . '.url', config))
|
||||||
|
let remote = expanded
|
||||||
|
let expanded = ''
|
||||||
|
endif
|
||||||
if empty(expanded)
|
if empty(expanded)
|
||||||
let bufname = &buftype =~# '^\%(nofile\|terminal\)$' ? '' : s:BufName('%')
|
let bufname = &buftype =~# '^\%(nofile\|terminal\)$' ? '' : s:BufName('%')
|
||||||
let expanded = s:DirRev(bufname)[1]
|
let expanded = s:DirRev(bufname)[1]
|
||||||
@@ -7305,7 +7310,6 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
|||||||
let type = 'blob'
|
let type = 'blob'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let config = fugitive#Config(dir)
|
|
||||||
if type ==# 'tree' && !empty(path)
|
if type ==# 'tree' && !empty(path)
|
||||||
let path = s:sub(path, '/\=$', '/')
|
let path = s:sub(path, '/\=$', '/')
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user