0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

runtime(getscript): CI: failure on powershell

Problem:  The CheckVimScriptURL() function does not work properly on
          pwershell. Most likely this is because curl is aliased to
          Invoke-WebRequest on Powershell and redirection seems to work
          slightly different
Solution: Disable CheckVimScriptURL() on Powershell and then simplify
          the curl download logic

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-05-11 18:30:24 +02:00
parent 411730e277
commit e62244f22d

View File

@@ -606,40 +606,24 @@ endfun
" Check status code of scriptaddr and downloadaddr " Check status code of scriptaddr and downloadaddr
" return v:true if the script is downloadable or v:false in case of errors " return v:true if the script is downloadable or v:false in case of errors
fun CheckVimScriptURL(script_id, src_id) fun CheckVimScriptURL(script_id, src_id)
if !executable('curl') " doesn't work with powershell
if !executable('curl') || &shell =~? 'pwsh\|powershell'
return v:true return v:true
endif endif
let output = has("win32") ? ' -o NUL ' : ' -o /dev/null ' let output = has("win32") ? ' -o NUL ' : ' -o /dev/null '
" Handle PowerShell differently let temp = tempname()
if &shell =~? '\<pwsh\>\|\<powershell\>' defer delete(temp)
" For PowerShell, use direct command output
let script_url = g:GetLatestVimScripts_scriptaddr . a:script_id let script_url = g:GetLatestVimScripts_scriptaddr . a:script_id
let script_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(script_url)
let script_status = system(script_cmd)
let script_status = substitute(script_status, '\n$', '', '')
let download_url = g:GetLatestVimScripts_downloadaddr . a:src_id let download_url = g:GetLatestVimScripts_downloadaddr . a:src_id
let download_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(download_url)
let download_status = system(download_cmd)
let download_status = substitute(download_status, '\n$', '', '')
else
" For other shells, use temporary files
let temp_script = tempname()
let temp_download = tempname()
let script_url = g:GetLatestVimScripts_scriptaddr . a:script_id let script_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(script_url) . ' >' . shellescape(temp)
let script_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(script_url) . ' >' . shellescape(temp_script)
call system(script_cmd) call system(script_cmd)
let script_status = readfile(temp_script, 'b')[0] let script_status = readfile(temp, 'b')[0]
call delete(temp_script)
let download_url = g:GetLatestVimScripts_downloadaddr . a:src_id let download_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(download_url) . ' >' . shellescape(temp)
let download_cmd = 'curl -s -I -w "%{http_code}"' . output . shellescape(download_url) . ' >' . shellescape(temp_download)
call system(download_cmd) call system(download_cmd)
let download_status = readfile(temp_download, 'b')[0] let download_status = readfile(temp, 'b')[0]
call delete(temp_download)
endif
if script_status !=# '200' if script_status !=# '200'
let s:message += [ printf('Error: Failed to reach script: %s', a:script_id) ] let s:message += [ printf('Error: Failed to reach script: %s', a:script_id) ]
@@ -651,7 +635,7 @@ fun CheckVimScriptURL(script_id, src_id)
return v:false return v:false
endif endif
return v:true return v:true
endfunction endfun
" --------------------------------------------------------------------- " ---------------------------------------------------------------------
" Restore Options: {{{1 " Restore Options: {{{1