onceover
onceover copied to clipboard
Replace versionomy with semver2 for parsing version numbers according to semver 2.0.0
As per a pull request for pact_broker, versionomy doesn't support valid semver 2.0.0 definitions.
We are building puppet modules with Jenkins and including build numbers and git hashes in order to track where a puppet module version was created from. Versionomy only supports x.y.z formats and not something like: x.y.z-pre.build_number.githash.
I will fork and create a pull request, but the basic code is:
require 'semver'
current = ::SemVer.parse(return_hash[:current_version], '%M.%m.%p%s%d')
latest = ::SemVer.parse(return_hash[:latest_version], '%M.%m.%p%s%d')
if current.major < latest.major
return_hash[:out_of_date] = "Major".red
elsif current.minor < latest.minor
return_hash[:out_of_date] = "Minor".yellow
elsif current.patch < latest.patch
return_hash[:out_of_date] = "Patch".green
elsif current.special < latest.special
return_hash[:out_of_date] = "Special".green
else
return_hash[:out_of_date] = "No".green
end