Class: Gitlab::QA::Support::GitlabVersionInfo
- Inherits:
 - 
      Object
      
        
- Object
 - Gitlab::QA::Support::GitlabVersionInfo
 
 
- 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
- 
  
    
      #initialize(current_version, edition)  ⇒ GitlabVersionInfo 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Get previous gitlab version.
 - 
  
    
      #latest_patch(version)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Get latest patch for specific version number.
 - 
  
    
      #next_version(version)  ⇒ String? 
    
    
  
  
  
  
  
  
  
  
  
    
Get next version major.minor from available releases.
 - 
  
    
      #previous_version(semver_component)  ⇒ Gem::Version 
    
    
  
  
  
  
  
  
  
  
  
    
Get N - 1 version number.
 - 
  
    
      #version_exists?(version)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Check if specific version exists in GitLab releases.
 
Constructor Details
#initialize(current_version, edition) ⇒ GitlabVersionInfo
Get previous gitlab version
      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”
      59 60 61 62 63 64 65 66  | 
    
      # File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 59 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  | 
  
#next_version(version) ⇒ String?
Get next version major.minor from available releases
next_version(“17.7.4”) => “17.8” next_version(“17.12.5”) => “18.0” next_version(“18.0.3”) => nil # when no next version exists
      77 78 79 80 81 82 83 84 85 86 87  | 
    
      # File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 77 def next_version(version) current_ver = Gem::Version.new(version) # Since versions are already sorted in descending order (newest first), # we need to reverse them to find the next version after current next_ver = versions.reverse.find { |ver| ver > current_ver } return nil unless next_ver [next_ver.segments[0], next_ver.segments[1]].join('.') # major.minor end  | 
  
#previous_version(semver_component) ⇒ Gem::Version
Get N - 1 version number
      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  | 
  
#version_exists?(version) ⇒ Boolean
Check if specific version exists in GitLab releases
version_exists?(“17.10.5”) => true version_exists?(“17.10.28”) => false
      47 48 49  | 
    
      # File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 47 def version_exists?(version) !!versions.find { |ver| ver.to_s == version } end  |