mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 01:43:57 +08:00
19db1a7d2a
* 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
493 B
Ruby
22 lines
493 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 = 5
|
|
TINY = 0
|
|
PRE = nil
|
|
|
|
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
|