discourse/lib/version.rb
David Taylor 0edffcc47d
FIX: Correct version comparison logic when comparing stable to beta (#10135)
* FIX: Correct version comparison logic when comparing stable to beta

For example, version 1.3.0 should be considered higher than 1.3.0.beta3. So `Discourse.has_needed_version?('1.3.0', '1.3.0.beta3')` should return true

* Switch to use Gem::Version to compare versions
2020-06-29 17:52:33 +10:00

22 lines
497 B
Ruby

# frozen_string_literal: true
module Discourse
VERSION_REGEXP = /\A\d+\.\d+\.\d+(\.beta\d+)?\z/ unless defined? ::Discourse::VERSION_REGEXP
# work around reloader
unless defined? ::Discourse::VERSION
module VERSION #:nodoc:
MAJOR = 2
MINOR = 6
TINY = 0
PRE = 'beta1'
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
end
def self.has_needed_version?(current, needed)
Gem::Version.new(current) >= Gem::Version.new(needed)
end
end