mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
0edffcc47d
* 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
22 lines
497 B
Ruby
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
|