debian-mirror-gitlab/lib/gitlab/import_export/version_checker.rb

36 lines
820 B
Ruby
Raw Normal View History

2016-06-22 15:30:34 +05:30
module Gitlab
module ImportExport
class VersionChecker
def self.check!(*args)
new(*args).check!
end
def initialize(shared:)
@shared = shared
end
def check!
version = File.open(version_file, &:readline)
verify_version!(version)
rescue => e
@shared.error(e)
false
end
private
def version_file
File.join(@shared.export_path, Gitlab::ImportExport.version_filename)
end
def verify_version!(version)
if Gem::Version.new(version) > Gem::Version.new(Gitlab::ImportExport.version)
2016-08-24 12:49:21 +05:30
raise Gitlab::ImportExport::Error.new("Import version mismatch: Required <= #{Gitlab::ImportExport.version} but was #{version}")
2016-06-22 15:30:34 +05:30
else
true
end
end
end
end
end