aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2016-10-08 16:34:54 +0200
committerJustin M. Keyes <justinkz@gmail.com>2016-10-08 16:34:54 +0200
commit31f6334aa8f8093ddfd2fd3ecf9fc438ad62a792 (patch)
treec6b0adcccd676270745f1327af346c57c17aa126
parent91d13bd86198c878b0b89d0ae31a8b8b0c8dd327 (diff)
downloadrneovim-31f6334aa8f8093ddfd2fd3ecf9fc438ad62a792.tar.gz
rneovim-31f6334aa8f8093ddfd2fd3ecf9fc438ad62a792.tar.bz2
rneovim-31f6334aa8f8093ddfd2fd3ecf9fc438ad62a792.zip
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.
-rw-r--r--runtime/autoload/health/provider.vim18
1 files changed, 15 insertions, 3 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index aadb2688b7..b1cfa8bf2b 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -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']
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 base = fnamemodify(nvim_path, ':h')
- for meta in glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1)
- for meta_line in readfile(meta)
+ let metas = glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1)
+ let metas = sort(metas, 's:compare')
+
+ if !empty(metas)
+ for meta_line in readfile(metas[0])
if meta_line =~# '^Version:'
let nvim_version = matchstr(meta_line, '^Version: \zs\S\+')
+ break
endif
endfor
- endfor
+ endif
let version_status = 'unknown'
if !s:is_bad_response(nvim_version) && !s:is_bad_response(pypi_version)