2016-05-16 10:39:42 +00:00
|
|
|
module Gitlab
|
|
|
|
module ImportExport
|
2016-06-02 08:59:54 +00:00
|
|
|
class VersionChecker
|
2016-05-16 10:39:42 +00:00
|
|
|
|
|
|
|
def self.restore(*args)
|
2016-06-02 08:59:54 +00:00
|
|
|
new(*args).check
|
2016-05-16 10:39:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(shared:)
|
|
|
|
@shared = shared
|
|
|
|
end
|
|
|
|
|
2016-06-02 08:59:54 +00:00
|
|
|
def check!
|
2016-05-16 10:39:42 +00:00
|
|
|
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)
|
2016-05-16 11:11:49 +00:00
|
|
|
if Gem::Version.new(version) > Gem::Version.new(Gitlab::ImportExport.version)
|
|
|
|
raise Gitlab::ImportExport::Error("Import version mismatch: Required <= #{Gitlab::ImportExport.version} but was #{version}")
|
2016-05-16 10:39:42 +00:00
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|