From be208ad60147ff3f2e65e97ee7cefff76c930c42 Mon Sep 17 00:00:00 2001 From: Igor Zolotarev <63460867+yngvar-antonsson@users.noreply.github.com> Date: Wed, 6 Dec 2023 08:48:53 +0100 Subject: [PATCH] Fix an error in cartridge.utils.version_is_at_least (#2167) --- CHANGELOG.rst | 6 ++++++ cartridge/utils.lua | 32 +++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 45661e9f5..7ac667adc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -29,6 +29,12 @@ Added - ``cartridge.cfg`` option ``disable_raft_on_small_clusters`` to disable Raft failover on clusters with less than 3 instances (default: ``true``). +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Fixed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- An error with ``cartridge.utils.version_is_at_least`` parsing. + ------------------------------------------------------------------------------- [2.8.4] - 2023-10-31 ------------------------------------------------------------------------------- diff --git a/cartridge/utils.lua b/cartridge/utils.lua index 19b26bd61..f33b0c975 100644 --- a/cartridge/utils.lua +++ b/cartridge/utils.lua @@ -500,8 +500,38 @@ end local is_enterprise = (tarantool.package == 'Tarantool Enterprise') local tnt_version = semver.parse(_TARANTOOL) + +--- Check if Tarantool version is at least the given one. +-- Tarantool's version has format: +-- +-- x.x.x-typen-commit-ghash +-- +-- * x.x.x - major, middle, minor release numbers; +-- * typen - release type and its optional number: alpha1, beta5, rc10. +-- Optional; +-- * commit - commit count since the latest release. Optional; +-- * ghash - latest commit hash in format g. Optional. +-- +-- @function +-- @local +-- +-- @int id_major +-- @int id_middle +-- @int id_minor +-- @string[opt] rel_type +-- @int[opt=0] rel_num +-- @int[opt=0] id_commit +-- +-- @treturn boolean local function version_is_at_least(...) - return tnt_version >= semver.new(...) + local id_major, id_middle, id_minor, rel_type, rel_num, id_commit = ... + if rel_num == nil then + rel_num = 0 + end + if id_commit == nil then + id_commit = 0 + end + return tnt_version >= semver.new(id_major, id_middle, id_minor, rel_type, rel_num, id_commit) end local feature = { ssl = (function()