From 6222a6033592b646fae22c06984157fb64c9c767 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 26 Jul 2023 14:48:08 +0100 Subject: [PATCH] DEV: Refactor `Discourse::VERSION` and add `-dev` support (#22807) For the Discourse 3.2 beta series, we intend to use a `-dev` suffix while beta versions are being developed in `main`/`tests-passed`. When a beta version is ready, it will be 'released' without the `-dev` suffix. This commit adds support for the `-dev` suffix, and also refactors `Discourse::VERSION` so that the canonical representation is a simple human-readable string. Constants for each segment are derived from that, so the interface remains unchanged. --- lib/version.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/version.rb b/lib/version.rb index 26db10bb5fa..ffc72bc9b8e 100644 --- a/lib/version.rb +++ b/lib/version.rb @@ -7,12 +7,16 @@ module Discourse # work around reloader unless defined?(::Discourse::VERSION) module VERSION #:nodoc: - MAJOR = 3 - MINOR = 1 - TINY = 0 - PRE = "beta6" + STRING = "3.1.0.beta6" - STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") + PARTS = STRING.split(".") + private_constant :PARTS + + MAJOR = PARTS[0].to_i + MINOR = PARTS[1].to_i + TINY = PARTS[2].to_i + PRE = PARTS[3]&.split("-", 2)&.first + DEV = PARTS[3]&.split("-", 2)&.second end end