mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
CheckHealth: choose correct path for the latest version (#5446)
If multiple versions of a package are installed, the provider health check could choose a wrong path: /usr/local/lib/python3.5/site-packages/neovim-0.1.10-py3.5.egg-info/PKG-INFO /usr/local/lib/python3.5/site-packages/neovim-0.1.9-py3.5.egg-info/PKG-INFO Prior to this change :CheckHealth could falsely show 0.1.9 as the installed version, since glob() doesn't enforce any predictable order. Now we sort all potential paths numerically in descending order and just look at the first path instead.
This commit is contained in:
parent
91d13bd861
commit
31f6334aa8
@ -104,15 +104,27 @@ function! s:version_info(python) abort
|
|||||||
return [python_version, 'unable to find neovim executable', pypi_version, 'unable to get neovim executable']
|
return [python_version, 'unable to find neovim executable', pypi_version, 'unable to get neovim executable']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Assuming that multiple versions of a package are installed, sort them
|
||||||
|
" numerically in descending order.
|
||||||
|
function! s:compare(metapath1, metapath2)
|
||||||
|
let a = matchstr(fnamemodify(a:metapath1, ':p:h:t'), '[0-9.]\+')
|
||||||
|
let b = matchstr(fnamemodify(a:metapath2, ':p:h:t'), '[0-9.]\+')
|
||||||
|
return a == b ? 0 : a > b ? 1 : -1
|
||||||
|
endfunction
|
||||||
|
|
||||||
let nvim_version = 'unable to find neovim version'
|
let nvim_version = 'unable to find neovim version'
|
||||||
let base = fnamemodify(nvim_path, ':h')
|
let base = fnamemodify(nvim_path, ':h')
|
||||||
for meta in glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1)
|
let metas = glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1)
|
||||||
for meta_line in readfile(meta)
|
let metas = sort(metas, 's:compare')
|
||||||
|
|
||||||
|
if !empty(metas)
|
||||||
|
for meta_line in readfile(metas[0])
|
||||||
if meta_line =~# '^Version:'
|
if meta_line =~# '^Version:'
|
||||||
let nvim_version = matchstr(meta_line, '^Version: \zs\S\+')
|
let nvim_version = matchstr(meta_line, '^Version: \zs\S\+')
|
||||||
|
break
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endif
|
||||||
|
|
||||||
let version_status = 'unknown'
|
let version_status = 'unknown'
|
||||||
if !s:is_bad_response(nvim_version) && !s:is_bad_response(pypi_version)
|
if !s:is_bad_response(nvim_version) && !s:is_bad_response(pypi_version)
|
||||||
|
Loading…
Reference in New Issue
Block a user