summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/import/gitlab_projects_controller.rb17
-rw-r--r--app/models/project.rb8
-rw-r--r--app/views/import/gitlab_projects/new.html.haml2
-rw-r--r--app/workers/project_import_worker.rb9
4 files changed, 23 insertions, 13 deletions
diff --git a/app/controllers/import/gitlab_projects_controller.rb b/app/controllers/import/gitlab_projects_controller.rb
index 0e94915765c..36be79a39c4 100644
--- a/app/controllers/import/gitlab_projects_controller.rb
+++ b/app/controllers/import/gitlab_projects_controller.rb
@@ -7,7 +7,8 @@ class Import::GitlabProjectsController < Import::BaseController
#TODO permissions stuff
def new
-
+ @namespace_id = project_params[:namespace_id]
+ @path = project_params[:path]
end
def status
@@ -27,14 +28,14 @@ class Import::GitlabProjectsController < Import::BaseController
def create
file = params[:file]
- # @project_name =
repo_owner = current_user.username
@target_namespace = params[:new_namespace].presence || repo_owner
- namespace = get_or_create_namespace || (render and return)
-
- @project = Project.create_from_import_job(current_user.id, File.expand_path(file.path))
+ @project = Project.create_from_import_job(current_user_id: current_user.id,
+ tmp_file: File.expand_path(file.path),
+ namespace_id: @namespace_id,
+ project_path: @path)
end
private
@@ -42,4 +43,10 @@ class Import::GitlabProjectsController < Import::BaseController
def verify_gitlab_project_import_enabled
render_404 unless gitlab_project_import_enabled?
end
+
+ def project_params
+ params.require(:project).permit(
+ :path, :namespace_id,
+ )
+ end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 18e647045cd..70921e02759 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -360,13 +360,13 @@ class Project < ActiveRecord::Base
where(id: user.authorized_projects.select(:id).reorder(nil))
end
- def create_from_import_job(current_user_id:, tmp_file:)
- job_id = ProjectImportWorker.perform_async(current_user_id, tmp_file)
+ def create_from_import_job(current_user_id:, tmp_file:, namespace_id:, project_path:)
+ job_id = ProjectImportWorker.perform_async(current_user_id, tmp_file, namespace_id, project_path)
if job_id
- Rails.logger.info "Import job started for #{path_with_namespace} with job ID #{job_id}"
+ Rails.logger.info "Import job started for export #{tmp_file} with job ID #{job_id}"
else
- Rails.logger.error "Import job failed to start for #{path_with_namespace}"
+ Rails.logger.error "Import job failed to start for #{tmp_file}"
end
end
end
diff --git a/app/views/import/gitlab_projects/new.html.haml b/app/views/import/gitlab_projects/new.html.haml
index 9e798b8a63f..323b7810c59 100644
--- a/app/views/import/gitlab_projects/new.html.haml
+++ b/app/views/import/gitlab_projects/new.html.haml
@@ -5,7 +5,7 @@
Import projects from FogBugz
%hr
-= form_tag import_gitlab_project_path, class: 'form-horizontal' do
+= form_tag import_gitlab_project_path, class: 'form-horizontal', multipart: true do
%p
To get started you add your project export file below.
.form-group
diff --git a/app/workers/project_import_worker.rb b/app/workers/project_import_worker.rb
index 6dd514b56a0..0e8b9552442 100644
--- a/app/workers/project_import_worker.rb
+++ b/app/workers/project_import_worker.rb
@@ -2,12 +2,15 @@ class ProjectImportWorker
include Sidekiq::Worker
include Gitlab::ShellAdapter
- sidekiq_options queue: :gitlab_shell
+ sidekiq_options queue: :gitlab_shell, retry: false
- def perform(current_user_id, tmp_file)
+ def perform(current_user_id, tmp_file, namespace_id, path)
current_user = User.find(current_user_id)
- project = Gitlab::ImportExport::ImportService.execute(archive_file: tmp_file, owner: current_user)
+ project = Gitlab::ImportExport::ImportService.execute(archive_file: tmp_file,
+ owner: current_user,
+ namespace_id: namespace_id,
+ project_path: path)
# TODO: Move this to import service
# if result[:status] == :error