summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-07-06 16:21:22 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-07-11 12:22:57 +0300
commita4b6707e63ca10eb64a92d45797eaad49e9c9f46 (patch)
treed2faaa1ca8504ba7148feebba00a3f8d8218fed4
parent85b0240c4b58a49b22c9dbff9451127ae817652a (diff)
downloadgitlab-ce-a4b6707e63ca10eb64a92d45797eaad49e9c9f46.tar.gz
Refactor manifest import code
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/controllers/import/manifest_controller.rb2
-rw-r--r--doc/user/project/import/img/manifest_upload.pngbin17455 -> 11595 bytes
-rw-r--r--doc/user/project/import/manifest.md2
-rw-r--r--lib/gitlab/manifest_import/project_creator.rb (renamed from lib/gitlab/manifest_import/importer.rb)20
-rw-r--r--spec/lib/gitlab/import_sources_spec.rb3
-rw-r--r--spec/lib/gitlab/manifest_import/project_creator_spec.rb (renamed from spec/lib/gitlab/manifest_import/importer_spec.rb)2
6 files changed, 12 insertions, 17 deletions
diff --git a/app/controllers/import/manifest_controller.rb b/app/controllers/import/manifest_controller.rb
index 0be9cc2468f..42e661325cf 100644
--- a/app/controllers/import/manifest_controller.rb
+++ b/app/controllers/import/manifest_controller.rb
@@ -47,7 +47,7 @@ class Import::ManifestController < Import::BaseController
project[:id] == params[:repo_id].to_i
end
- project = Gitlab::ManifestImport::Importer.new(repository, group, current_user).execute
+ project = Gitlab::ManifestImport::ProjectCreator.new(repository, group, current_user).execute
if project.persisted?
render json: ProjectSerializer.new.represent(project)
diff --git a/doc/user/project/import/img/manifest_upload.png b/doc/user/project/import/img/manifest_upload.png
index 385df3aa8ce..ea68e7ffc6a 100644
--- a/doc/user/project/import/img/manifest_upload.png
+++ b/doc/user/project/import/img/manifest_upload.png
Binary files differ
diff --git a/doc/user/project/import/manifest.md b/doc/user/project/import/manifest.md
index 16c7e77d033..136ba310da1 100644
--- a/doc/user/project/import/manifest.md
+++ b/doc/user/project/import/manifest.md
@@ -10,7 +10,7 @@ You can do it by following next steps:
1. Click on the **Manifest file** button
1. Provide GitLab with a manifest xml file
1. Select a group you want to import to (you need to create a group first if you don't have one)
-1. Click **Import projects**
+1. Click **Continue to the next step**
1. You will be redirected to the import status page with projects list based on manifest file
1. Check the list and click 'Import all repositories' to start import.
diff --git a/lib/gitlab/manifest_import/importer.rb b/lib/gitlab/manifest_import/project_creator.rb
index 8ffeb0a4143..9ccd32c3a3b 100644
--- a/lib/gitlab/manifest_import/importer.rb
+++ b/lib/gitlab/manifest_import/project_creator.rb
@@ -1,21 +1,15 @@
module Gitlab
module ManifestImport
- class Importer
- attr_reader :repository, :destination, :user
+ class ProjectCreator
+ attr_reader :repository, :destination, :current_user
- def initialize(repository, destination, user)
+ def initialize(repository, destination, current_user)
@repository = repository
@destination = destination
- @user = user
+ @current_user = current_user
end
def execute
- import_project
- end
-
- private
-
- def import_project
group_full_path, _, project_path = repository[:path].rpartition('/')
group_full_path = File.join(destination.full_path, group_full_path) if destination
group = Group.find_by_full_path(group_full_path) ||
@@ -30,16 +24,18 @@ module Gitlab
visibility_level: destination.visibility_level
}
- Projects::CreateService.new(user, params).execute
+ Projects::CreateService.new(current_user, params).execute
end
+ private
+
def create_group_with_parents(full_path)
params = {
group_path: full_path,
visibility_level: destination.visibility_level
}
- Groups::NestedCreateService.new(user, params).execute
+ Groups::NestedCreateService.new(current_user, params).execute
end
end
end
diff --git a/spec/lib/gitlab/import_sources_spec.rb b/spec/lib/gitlab/import_sources_spec.rb
index 7734f48de86..25827423914 100644
--- a/spec/lib/gitlab/import_sources_spec.rb
+++ b/spec/lib/gitlab/import_sources_spec.rb
@@ -50,7 +50,6 @@ describe Gitlab::ImportSources do
fogbugz
gitlab_project
gitea
- manifest
)
expect(described_class.importer_names).to eq(expected)
@@ -67,7 +66,7 @@ describe Gitlab::ImportSources do
'git' => nil,
'gitlab_project' => Gitlab::ImportExport::Importer,
'gitea' => Gitlab::LegacyGithubImport::Importer,
- 'manifest' => Gitlab::ManifestImport::Importer
+ 'manifest' => nil
}
import_sources.each do |name, klass|
diff --git a/spec/lib/gitlab/manifest_import/importer_spec.rb b/spec/lib/gitlab/manifest_import/project_creator_spec.rb
index 55f3c347386..1d01d437535 100644
--- a/spec/lib/gitlab/manifest_import/importer_spec.rb
+++ b/spec/lib/gitlab/manifest_import/project_creator_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::ManifestImport::Importer, :postgresql do
+describe Gitlab::ManifestImport::ProjectCreator, :postgresql do
let(:group) { create(:group) }
let(:user) { create(:user) }
let(:repository) do