Module: RubocopPr::Repositories::Github::Checks::VerifyHubVersion

Defined in:
lib/rubocop_pr/repositories/github/checks/verify_hub_version.rb

Overview

Check, if ‘hub` installed and have right version

Class Method Summary collapse

Class Method Details

.call(options) ⇒ Object



9
10
11
12
13
# File 'lib/rubocop_pr/repositories/github/checks/verify_hub_version.rb', line 9

def call(options)
  return true if system_hub_version >= Gem::Version.new(options.hub_version)
  warn "Script was tested with hub version #{HUB_VERSION}, while you are using #{system_hub_version}"
  true
end

.hub_versionObject



22
23
24
# File 'lib/rubocop_pr/repositories/github/checks/verify_hub_version.rb', line 22

def hub_version
  `hub  --version`
end

.system_hub_versionObject



15
16
17
18
19
20
# File 'lib/rubocop_pr/repositories/github/checks/verify_hub_version.rb', line 15

def system_hub_version
  matches = hub_version.match(/hub version (?<hub_version>(.*))/)
  Gem::Version.new matches.captures.last
rescue StandardError
  raise "Robopop requires https://github.com/github/hub version >= #{RubocopPr::HUB_VERSION}"
end