From cc281afb27365adef2d24c85f83686cc8b829187 Mon Sep 17 00:00:00 2001 From: Brandon Labuschagne Date: Mon, 14 Jan 2019 16:10:19 +0000 Subject: Resolve "Add "What's new" menu item in top navigation" --- lib/gitlab.rb | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'lib/gitlab.rb') diff --git a/lib/gitlab.rb b/lib/gitlab.rb index 2ef54658a11..074d04fc32a 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -27,12 +27,52 @@ module Gitlab end end + def self.version_info + Gitlab::VersionInfo.parse(Gitlab::VERSION) + end + COM_URL = 'https://gitlab.com'.freeze APP_DIRS_PATTERN = %r{^/?(app|config|ee|lib|spec|\(\w*\))} SUBDOMAIN_REGEX = %r{\Ahttps://[a-z0-9]+\.gitlab\.com\z} VERSION = File.read(root.join("VERSION")).strip.freeze INSTALLATION_TYPE = File.read(root.join("INSTALLATION_TYPE")).strip.freeze + def self.pre_release? + VERSION.include?('pre') + end + + def self.final_release? + !VERSION.include?('rc') && !pre_release? + end + + def self.minor_release + "#{version_info.major}.#{version_info.minor}" + end + + def self.prev_minor_release + "#{version_info.major}.#{version_info.minor - 1}" + end + + def self.prev_major_release + "#{version_info.major.to_i - 1}" + end + + def self.new_major_release? + version_info.minor.to_i.zero? + end + + def self.previous_release + if version_info.minor_version? + if version_info.patch_version? + minor_release + else + prev_minor_release + end + else + prev_major_release + end + end + def self.com? # Check `gl_subdomain?` as well to keep parity with gitlab.com Gitlab.config.gitlab.url == COM_URL || gl_subdomain? @@ -49,12 +89,4 @@ module Gitlab def self.dev_env_or_com? Rails.env.development? || org? || com? end - - def self.pre_release? - VERSION.include?('pre') - end - - def self.version_info - Gitlab::VersionInfo.parse(Gitlab::VERSION) - end end -- cgit v1.2.3