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

106 lines
2.1 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2016-06-22 15:30:34 +05:30
module Gitlab
module ImportExport
extend self
2019-10-12 21:52:04 +05:30
# 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
2019-12-04 20:38:33 +05:30
VERSION = '0.2.4'
2016-08-24 12:49:21 +05:30
FILENAME_LIMIT = 50
2016-06-22 15:30:34 +05:30
def export_path(relative_path:)
File.join(storage_path, relative_path)
end
def storage_path
2019-12-26 22:10:19 +05:30
File.join(Settings.shared['path'], 'tmp/gitlab_exports')
2016-06-22 15:30:34 +05:30
end
2016-08-24 12:49:21 +05:30
def import_upload_path(filename:)
File.join(storage_path, 'uploads', filename)
end
2016-06-22 15:30:34 +05:30
def project_filename
"project.json"
end
def project_bundle_filename
"project.bundle"
end
2019-10-12 21:52:04 +05:30
def lfs_objects_filename
"lfs-objects.json"
end
def lfs_objects_storage
"lfs-objects"
end
2019-12-21 20:55:43 +05:30
def wiki_repo_bundle_filename
"project.wiki.bundle"
end
2020-05-24 23:13:21 +05:30
def design_repo_bundle_filename
'project.design.bundle'
end
2020-04-08 14:13:33 +05:30
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
2016-06-22 15:30:34 +05:30
def config_file
2020-04-08 14:13:33 +05:30
Rails.root.join('lib/gitlab/import_export/project/import_export.yml')
2016-06-22 15:30:34 +05:30
end
def version_filename
'VERSION'
end
2020-03-09 13:42:32 +05:30
def gitlab_version_filename
'GITLAB_VERSION'
end
def gitlab_revision_filename
'GITLAB_REVISION'
end
2019-12-26 22:10:19 +05:30
def export_filename(exportable:)
basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{exportable.full_path.tr('/', '_')}"
2016-08-24 12:49:21 +05:30
"#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
end
2016-06-22 15:30:34 +05:30
def version
VERSION
end
def reset_tokens?
true
end
2019-12-26 22:10:19 +05:30
def group_filename
'group.json'
end
2020-05-24 23:13:21 +05:30
def legacy_group_config_file
Rails.root.join('lib/gitlab/import_export/group/legacy_import_export.yml')
end
2019-12-26 22:10:19 +05:30
def group_config_file
2020-04-08 14:13:33 +05:30
Rails.root.join('lib/gitlab/import_export/group/import_export.yml')
2019-12-26 22:10:19 +05:30
end
2016-06-22 15:30:34 +05:30
end
end
2019-12-21 20:55:43 +05:30
Gitlab::ImportExport.prepend_if_ee('EE::Gitlab::ImportExport')