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+)/
COMPONENT_PATTERN =
/^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/
VersionNotFoundError =
Class.new(RuntimeError)

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



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

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” latest_patch(Gem::Version.new(“14.10.5”)) => “14.10.5”

Parameters:

  • version (Gem::Version)

Returns:

  • (String)


47
48
49
50
51
52
53
54
# File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 47

def latest_patch(version)
  # check if version is already a patch version
  return version if version.to_s.split('.').size == 3

  versions.find { |ver| ver.to_s.match?(/^#{version}\./) }.tap do |ver|
    raise_version_not_found("Latest patch version for version #{version}") unless ver
  end
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)


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

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