Add alternatives to :GBrowse ++remote=

In the same way Vim requires custom commands to start with an uppercase
letter, I'm starting to think we should self-impose the same constraint
on custom ++options.  Also, let's throw "Git" in there, just to allow
this to be truly unique if necessary.

This also allows a special remote argument of ".git" to refer to the
local repository.  A possible use of this would be a local gitweb
handler.
This commit is contained in:
Tim Pope
2021-08-21 16:33:51 -04:00
parent 4e6b7b6ce9
commit 57eeed2545

View File

@@ -1170,7 +1170,9 @@ function! fugitive#RemoteUrl(...) abort
else
let url = remove(args, 0)
endif
if url !~# ':\|^/\|^\.\.\=/'
if url ==# '.git'
let url = FugitiveGitDir(config)
elseif url !~# ':\|^/\|^\.\.\=/'
let url = FugitiveConfigGet('remote.' . url . '.url', config)
endif
let instead_of = []
@@ -6794,11 +6796,11 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo
let dir = s:Dir()
try
let arg = a:arg
if arg =~# '^++remote='
let remote = matchstr(arg, '^++remote=\zs\S\+')
if arg =~# '^++\%([Gg]it\)\=[Rr]emote='
let remote = matchstr(arg, '^++\%([Gg]it\)\=[Rr]emote=\zs\S\+')
let arg = matchstr(arg, '\s\zs\S.*')
endif
let validremote = '\.\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\='
let validremote = '\.\%(git\)\=\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\='
if arg ==# '-'
let remote = ''
let rev = ''