diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /lib/gitlab/import_export/importer.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'lib/gitlab/import_export/importer.rb')
-rw-r--r-- | lib/gitlab/import_export/importer.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/gitlab/import_export/importer.rb b/lib/gitlab/import_export/importer.rb index 4b761eb86ae..b1219384732 100644 --- a/lib/gitlab/import_export/importer.rb +++ b/lib/gitlab/import_export/importer.rb @@ -34,7 +34,7 @@ module Gitlab attr_accessor :archive_file, :current_user, :project, :shared def restorers - [repo_restorer, wiki_restorer, project_tree, avatar_restorer, + [repo_restorer, wiki_restorer, project_tree, avatar_restorer, design_repo_restorer, uploads_restorer, lfs_restorer, statistics_restorer, snippets_repo_restorer] end @@ -71,6 +71,12 @@ module Gitlab wiki_enabled: project.wiki_enabled?) end + def design_repo_restorer + Gitlab::ImportExport::DesignRepoRestorer.new(path_to_bundle: design_repo_path, + shared: shared, + project: project) + end + def uploads_restorer Gitlab::ImportExport::UploadsRestorer.new(project: project, shared: shared) end @@ -101,6 +107,10 @@ module Gitlab File.join(shared.export_path, Gitlab::ImportExport.wiki_repo_bundle_filename) end + def design_repo_path + File.join(shared.export_path, Gitlab::ImportExport.design_repo_bundle_filename) + end + def remove_import_file upload = project.import_export_upload @@ -111,13 +121,17 @@ module Gitlab end def overwrite_project - return unless can?(current_user, :admin_namespace, project.namespace) + return true unless overwrite_project? - if overwrite_project? - ::Projects::OverwriteProjectService.new(project, current_user) - .execute(project_to_overwrite) + unless can?(current_user, :admin_namespace, project.namespace) + message = "User #{current_user&.username} (#{current_user&.id}) cannot overwrite a project in #{project.namespace.path}" + @shared.error(::Projects::ImportService::PermissionError.new(message)) + return false end + ::Projects::OverwriteProjectService.new(project, current_user) + .execute(project_to_overwrite) + true end @@ -137,5 +151,3 @@ module Gitlab end end end - -Gitlab::ImportExport::Importer.prepend_if_ee('EE::Gitlab::ImportExport::Importer') |