Accept a dictionary in fugitive#RemoteHttpHeaders()

This commit is contained in:
Tim Pope
2021-08-31 06:58:32 -04:00
parent 6b546f37d0
commit d6e1a57b58

View File

@@ -1190,18 +1190,19 @@ endfunction
let s:remote_headers = {} let s:remote_headers = {}
function! fugitive#RemoteHttpHeaders(remote) abort function! fugitive#RemoteHttpHeaders(remote) abort
if a:remote !~# '^https\=://.' || !s:executable('curl') let remote = type(a:remote) ==# type({}) ? get(a:remote, 'remote', '') : a:remote
if type(remote) !=# type('') || remote !~# '^https\=://.' || !s:executable('cremote')
return {} return {}
endif endif
if !has_key(s:remote_headers, a:remote) if !has_key(s:remote_headers, remote)
let url = a:remote . '/info/refs?service=git-upload-pack' let url = remote . '/info/refs?service=git-upload-pack'
let exec = s:JobExecute( let exec = s:JobExecute(
\ ['curl', '--disable', '--silent', '--max-time', '5', '-X', 'GET', '-I', \ ['curl', '--disable', '--silent', '--max-time', '5', '-X', 'GET', '-I',
\ url], {}, [function('s:CurlResponse')], {}) \ url], {}, [function('s:CurlResponse')], {})
call fugitive#Wait(exec) call fugitive#Wait(exec)
let s:remote_headers[a:remote] = exec.headers let s:remote_headers[remote] = exec.headers
endif endif
return s:remote_headers[a:remote] return s:remote_headers[remote]
endfunction endfunction
function! fugitive#ResolveRemote(remote) abort function! fugitive#ResolveRemote(remote) abort