mirror of https://github.com/dense-analysis/ale
Fix parsing the third part of version string (#2355)
* Fix parsing the third part of version string * Add test * Test: fix checking cached version
This commit is contained in:
parent
365ffae6c4
commit
5f03bae41c
|
@ -14,10 +14,10 @@ function! ale#semver#GetVersion(executable, version_lines) abort
|
|||
let l:version = get(s:version_cache, a:executable, [])
|
||||
|
||||
for l:line in a:version_lines
|
||||
let l:match = matchlist(l:line, '\v(\d+)\.(\d+)\.?(\d?)')
|
||||
let l:match = matchlist(l:line, '\v(\d+)\.(\d+)(\.(\d+))?')
|
||||
|
||||
if !empty(l:match)
|
||||
let l:version = [l:match[1] + 0, l:match[2] + 0, l:match[3] + 0]
|
||||
let l:version = [l:match[1] + 0, l:match[2] + 0, l:match[4] + 0]
|
||||
let s:version_cache[a:executable] = l:version
|
||||
|
||||
break
|
||||
|
|
|
@ -15,7 +15,8 @@ Execute(GetVersion should return an empty list when no vesrion can be found):
|
|||
Execute(GetVersion should cache the version):
|
||||
AssertEqual [], ale#semver#GetVersion('dummy', [])
|
||||
AssertEqual [3, 4, 7], ale#semver#GetVersion('dummy', ['Version 3.4.7'])
|
||||
AssertEqual [3, 4, 7], ale#semver#GetVersion('dummy', [])
|
||||
AssertEqual [3, 4, 17], ale#semver#GetVersion('dummy', ['Version 3.4.17'])
|
||||
AssertEqual [3, 4, 17], ale#semver#GetVersion('dummy', [])
|
||||
|
||||
Execute(GetVersion should tolerate missing patch numbers):
|
||||
" This goes against the semver spec, but we handle it anyway.
|
||||
|
|
Loading…
Reference in New Issue