mirror of
https://github.com/tpope/vim-rhubarb.git
synced 2025-12-06 12:14:26 +08:00
Use FugitiveExecute() to call curl if available
I'm not in love with this API, so intercept any "I changed my mind" exception and fall back to system().
This commit is contained in:
@@ -194,6 +194,16 @@ function! rhubarb#Request(path, ...) abort
|
||||
endif
|
||||
let options = a:0 ? a:1 : {}
|
||||
let args = s:curl_arguments(path, options)
|
||||
if exists('*FugitiveExecute') && v:version >= 800
|
||||
try
|
||||
if has_key(options, 'callback')
|
||||
return FugitiveExecute({'argv': args}, { r -> r.exit_status || r.stdout ==# [''] ? '' : options.callback(json_decode(join(r.stdout, ' '))) })
|
||||
endif
|
||||
let raw = join(FugitiveExecute({'argv': args}).stdout, ' ')
|
||||
return empty(raw) ? raw : json_decode(raw)
|
||||
catch /^fugitive:/
|
||||
endtry
|
||||
endif
|
||||
let raw = system(join(map(copy(args), 's:shellesc(v:val)'), ' '))
|
||||
if has_key(options, 'callback')
|
||||
if !v:shell_error && !empty(raw)
|
||||
|
||||
Reference in New Issue
Block a user