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.
This commit is contained in:
David Taylor 2023-07-26 14:48:08 +01:00 committed by GitHub
parent 3f29a2ab90
commit 6222a60335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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