gitlab-org--gitlab-foss/lib/gitlab/import_export.rb

102 lines
2.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Gitlab
2016-03-07 12:26:15 -05:00
module ImportExport
extend self
# For every version update the version history in these docs must be kept up to date:
# - development/import_export.md
# - user/project/settings/import_export.md
VERSION = '0.2.4'
FILENAME_LIMIT = 50
2016-05-16 06:04:31 -04:00
def export_path(relative_path:)
2016-04-22 06:18:11 -04:00
File.join(storage_path, relative_path)
2016-03-07 12:26:15 -05:00
end
def storage_path
File.join(Settings.shared['path'], 'tmp/gitlab_exports')
2016-03-07 12:26:15 -05:00
end
2016-05-13 11:39:03 -04:00
def import_upload_path(filename:)
File.join(storage_path, 'uploads', filename)
end
2016-05-13 11:39:03 -04:00
def project_filename
"project.json"
end
def project_bundle_filename
"project.bundle"
end
2016-05-16 06:04:31 -04:00
def lfs_objects_filename
"lfs-objects.json"
end
def lfs_objects_storage
"lfs-objects"
end
def wiki_repo_bundle_filename
"project.wiki.bundle"
end
def snippet_repo_bundle_dir
'snippets'
end
def snippets_repo_bundle_path(absolute_path)
File.join(absolute_path, ::Gitlab::ImportExport.snippet_repo_bundle_dir)
end
def snippet_repo_bundle_filename_for(snippet)
"#{snippet.hexdigest}.bundle"
end
def config_file
Rails.root.join('lib/gitlab/import_export/project/import_export.yml')
end
2016-05-16 06:04:31 -04:00
def version_filename
'VERSION'
end
2016-05-16 07:28:11 -04:00
def gitlab_version_filename
'GITLAB_VERSION'
end
def gitlab_revision_filename
'GITLAB_REVISION'
end
def export_filename(exportable:)
basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{exportable.full_path.tr('/', '_')}"
"#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
end
2016-05-16 07:28:11 -04:00
def version
VERSION
end
def reset_tokens?
true
end
def group_filename
'group.json'
end
def legacy_group_config_file
Rails.root.join('lib/gitlab/import_export/group/legacy_import_export.yml')
end
def group_config_file
Rails.root.join('lib/gitlab/import_export/group/import_export.yml')
end
2016-03-07 12:26:15 -05:00
end
end
Gitlab::ImportExport.prepend_if_ee('EE::Gitlab::ImportExport')