Class: Gitlab::QA::Support::GitlabVersionInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/support/gitlab_version_info.rb

Constant Summary collapse

VERSION_PATTERN =
/^(?<version>\d+\.\d+\.\d+)/.freeze
COMPONENT_PATTERN =
/^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(current_version, edition) ⇒ GitlabVersionInfo

Get previous gitlab version

Parameters:

  • current_version (String)
  • edition (String)

    GitLab edition - ee or ce



14
15
16
17
18
# File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 14

def initialize(current_version, edition)
  @current_version = current_version
  @edition = edition
  @logger = Runtime::Logger.logger
end

Instance Method Details

#latest_patch(version) ⇒ String

Get latest patch for specific version number

latest_patch(Gem::Version.new(“14.10”)) => “14.10.5”

Parameters:

  • version (Gem::Version)

Returns:

  • (String)


44
45
46
# File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 44

def latest_patch(version)
  versions.find { |ver| ver.to_s.match?(/^#{version}/) }
end

#previous_version(semver_component) ⇒ Gem::Version

Get N - 1 version number

Parameters:

  • semver_component (String)

    version number component for previous version detection - major|minor|patch

Returns:

  • (Gem::Version)


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 24

def previous_version(semver_component)
  case semver_component
  when "major"
    previous_major
  when "minor"
    previous_minor
  when "patch"
    previous_patch
  else
    raise("Unsupported semver component, must be major|minor|patch")
  end
end