2018-10-22 03:00:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-14 10:57:25 -04:00
|
|
|
module Gitlab
|
2016-03-07 12:26:15 -05:00
|
|
|
module ImportExport
|
|
|
|
extend self
|
|
|
|
|
2019-07-24 07:23:51 -04:00
|
|
|
# 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-08-31 15:25:25 -04:00
|
|
|
VERSION = '0.2.4'
|
2016-07-15 06:47:06 -04:00
|
|
|
FILENAME_LIMIT = 50
|
2016-05-16 06:04:31 -04:00
|
|
|
|
2016-03-08 09:53:32 -05: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
|
2019-11-11 16:06:20 -05:00
|
|
|
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
|
|
|
|
2016-08-02 05:32:28 -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
|
|
|
|
2019-07-24 07:23:51 -04:00
|
|
|
def lfs_objects_filename
|
|
|
|
"lfs-objects.json"
|
|
|
|
end
|
|
|
|
|
|
|
|
def lfs_objects_storage
|
|
|
|
"lfs-objects"
|
|
|
|
end
|
|
|
|
|
2019-09-27 05:06:26 -04:00
|
|
|
def wiki_repo_bundle_filename
|
|
|
|
"project.wiki.bundle"
|
|
|
|
end
|
|
|
|
|
2020-05-11 20:10:11 -04:00
|
|
|
def design_repo_bundle_filename
|
|
|
|
'project.design.bundle'
|
|
|
|
end
|
|
|
|
|
2020-03-06 13:08:08 -05:00
|
|
|
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-13 03:37:58 -04:00
|
|
|
def config_file
|
2020-02-26 13:09:24 -05:00
|
|
|
Rails.root.join('lib/gitlab/import_export/project/import_export.yml')
|
2016-06-13 03:37:58 -04:00
|
|
|
end
|
|
|
|
|
2016-05-16 06:04:31 -04:00
|
|
|
def version_filename
|
|
|
|
'VERSION'
|
|
|
|
end
|
2016-05-16 07:28:11 -04:00
|
|
|
|
2019-12-23 19:07:31 -05:00
|
|
|
def gitlab_version_filename
|
|
|
|
'GITLAB_VERSION'
|
|
|
|
end
|
|
|
|
|
|
|
|
def gitlab_revision_filename
|
|
|
|
'GITLAB_REVISION'
|
|
|
|
end
|
|
|
|
|
2019-11-11 16:06:20 -05:00
|
|
|
def export_filename(exportable:)
|
|
|
|
basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{exportable.full_path.tr('/', '_')}"
|
2016-07-15 06:47:06 -04:00
|
|
|
|
|
|
|
"#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
|
|
|
|
end
|
|
|
|
|
2016-05-16 07:28:11 -04:00
|
|
|
def version
|
|
|
|
VERSION
|
|
|
|
end
|
2016-05-19 09:36:20 -04:00
|
|
|
|
|
|
|
def reset_tokens?
|
|
|
|
true
|
|
|
|
end
|
2019-11-11 16:06:20 -05:00
|
|
|
|
|
|
|
def group_filename
|
|
|
|
'group.json'
|
|
|
|
end
|
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
def legacy_group_config_file
|
|
|
|
Rails.root.join('lib/gitlab/import_export/group/legacy_import_export.yml')
|
2019-11-11 16:06:20 -05:00
|
|
|
end
|
2020-04-23 17:09:31 -04:00
|
|
|
|
|
|
|
def group_config_file
|
|
|
|
Rails.root.join('lib/gitlab/import_export/group/import_export.yml')
|
|
|
|
end
|
2021-05-05 08:10:33 -04:00
|
|
|
|
|
|
|
def group_wiki_repo_bundle_filename(group_id)
|
|
|
|
"#{group_id}.wiki.bundle"
|
|
|
|
end
|
|
|
|
|
|
|
|
def group_wiki_repo_bundle_path(shared, filename)
|
|
|
|
File.join(shared.export_path, 'repositories', filename)
|
|
|
|
end
|
|
|
|
|
|
|
|
def group_wiki_repo_bundle_full_path(shared, group_id)
|
|
|
|
group_wiki_repo_bundle_path(shared, group_wiki_repo_bundle_filename(group_id))
|
|
|
|
end
|
2016-03-07 12:26:15 -05:00
|
|
|
end
|
|
|
|
end
|
2019-09-27 05:06:26 -04:00
|
|
|
|
2021-05-05 08:10:33 -04:00
|
|
|
Gitlab::ImportExport.prepend_mod
|