omnibus_gitlab_version.rb 778 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# frozen_string_literal: true

module ReleaseTools
  class OmnibusGitlabVersion < Version
    VERSION_REGEX = %r{
      \A(?<major>\d+)
      \.(?<minor>\d+)
      (\.(?<patch>\d+))?
      (\+)?
      (?<rc>rc(?<rc_number>\d*))?
      (\.)?
      (?<edition>ce|ee)?
      (\.\d+)?\z
14
    }x.freeze
15 16 17 18 19

    def ee?
      edition == 'ee'
    end

20 21 22
    def to_ce
      return self unless ee?

23
      self.class.new(to_s.sub(/(\+|\.)ee/, '\1ce'))
24 25 26 27 28
    end

    def to_ee
      return self if ee?

29
      self.class.new(to_s.sub(/(\+|\.)ce/, '\1ee'))
30 31
    end

32 33 34 35 36 37 38 39 40 41 42 43
    def edition
      @edition ||= extract_from_version(:edition, fallback: 'ce')
    end

    def tag
      str = +"#{to_patch}+"
      str << "rc#{rc}." if rc?
      str << (ee? ? 'ee' : 'ce')
      str << '.0'
    end
  end
end