From 3ac12b69399fc1f85e9a8ad2e76dc4e1f938f7d2 Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 27 Jan 2019 10:56:02 +0000 Subject: [PATCH] Fix #2216 - Tolerate versions without path numbers --- autoload/ale/semver.vim | 2 +- test/test_semver_utils.vader | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/ale/semver.vim b/autoload/ale/semver.vim index 6b0fd34a..8f549c9f 100644 --- a/autoload/ale/semver.vim +++ b/autoload/ale/semver.vim @@ -14,7 +14,7 @@ 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] diff --git a/test/test_semver_utils.vader b/test/test_semver_utils.vader index 30e9e818..cd0381dd 100644 --- a/test/test_semver_utils.vader +++ b/test/test_semver_utils.vader @@ -17,6 +17,10 @@ Execute(GetVersion should cache the version): AssertEqual [3, 4, 7], ale#semver#GetVersion('dummy', ['Version 3.4.7']) AssertEqual [3, 4, 7], ale#semver#GetVersion('dummy', []) +Execute(GetVersion should tolerate missing patch numbers): + " This goes against the semver spec, but we handle it anyway. + AssertEqual [3, 4, 0], ale#semver#GetVersion('dummy', ['Version 3.4']) + Execute(HasVersion should return 1 when the version has been cached): call ale#semver#GetVersion('dummy', []) AssertEqual 0, ale#semver#HasVersion('dummy')