summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/import/gitlab_projects_controller.rb10
-rw-r--r--app/controllers/projects_controller.rb2
-rw-r--r--app/models/project.rb4
-rw-r--r--app/models/todo.rb4
-rw-r--r--app/services/projects/create_service.rb4
-rw-r--r--app/services/projects/import_service.rb7
-rw-r--r--app/views/projects/edit.html.haml13
-rw-r--r--app/workers/project_import_worker.rb8
8 files changed, 34 insertions, 18 deletions
diff --git a/app/controllers/import/gitlab_projects_controller.rb b/app/controllers/import/gitlab_projects_controller.rb
index 90b4ff8b2ca..98a9b5f1018 100644
--- a/app/controllers/import/gitlab_projects_controller.rb
+++ b/app/controllers/import/gitlab_projects_controller.rb
@@ -12,12 +12,10 @@ class Import::GitlabProjectsController < Import::BaseController
return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive." })
end
- @project = Project.create_from_import_job(current_user_id: current_user.id,
- tmp_file: File.expand_path(params[:file].path),
- namespace_id: project_params[:namespace_id],
- project_path: project_params[:path])
-
- @project = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, current_user, access_params).execute
+ @project = Gitlab::GitlabImport::ProjectCreator.new(Namespace.find(project_params[:namespace_id]),
+ current_user,
+ File.expand_path(params[:file].path),
+ project_params[:path]).execute
flash[:notice] = "The project import has been started."
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 5c657290046..a1d58144399 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -190,7 +190,7 @@ class ProjectsController < Projects::ApplicationController
redirect_to(
edit_project_path(@project),
- notice: "Project export successfully started"
+ notice: "Project export successfully started."
)
end
diff --git a/app/models/project.rb b/app/models/project.rb
index ab7947a0880..1625e880220 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -492,6 +492,10 @@ class Project < ActiveRecord::Base
Gitlab::UrlSanitizer.new(import_url).masked_url
end
+ def gitlab_project_import?
+ import_type == 'gitlab_project'
+ end
+
def check_limit
unless creator.can_create_project? or namespace.kind == 'group'
projects_limit = creator.projects_limit
diff --git a/app/models/todo.rb b/app/models/todo.rb
index b0401463269..3a091373329 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -45,10 +45,6 @@ class Todo < ActiveRecord::Base
target_type == "Commit"
end
- def for_project?
- target_type == "Project"
- end
-
# override to return commits, which are not active record
def target
if for_commit?
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index 61cac5419ad..7e467541539 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -52,9 +52,11 @@ module Projects
save_project_and_import_data(import_data)
+ @project.import_url = download_export_namespace_project_path(@project.namespace, @project) if @project.gitlab_project_import?
+
@project.import_start if @project.import?
- after_create_actions if @project.persisted?
+ after_create_actions if @project.persisted? && !@project.gitlab_project_import?
if @project.errors.empty?
@project.add_import_job if @project.import?
diff --git a/app/services/projects/import_service.rb b/app/services/projects/import_service.rb
index c4838d31f2f..b4b4c34b012 100644
--- a/app/services/projects/import_service.rb
+++ b/app/services/projects/import_service.rb
@@ -9,7 +9,8 @@ module Projects
'fogbugz',
'gitlab',
'github',
- 'google_code'
+ 'google_code',
+ 'gitlab_project'
]
def execute
@@ -37,7 +38,7 @@ module Projects
def import_repository
begin
- gitlab_shell.import_repository(project.path_with_namespace, project.import_url)
+ gitlab_shell.import_repository(project.path_with_namespace, project.import_url) unless @project.gitlab_project_import?
rescue Gitlab::Shell::Error => e
raise Error, "Error importing repository #{project.import_url} into #{project.path_with_namespace} - #{e.message}"
end
@@ -58,6 +59,8 @@ module Projects
end
def importer
+ return Gitlab::ImportExport::Importer if @project.gitlab_project_import?
+
class_name = "Gitlab::#{project.import_type.camelize}Import::Importer"
class_name.constantize.new(project)
end
diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml
index 8449fe1e4e0..9a832eceaf5 100644
--- a/app/views/projects/edit.html.haml
+++ b/app/views/projects/edit.html.haml
@@ -120,6 +120,19 @@
= link_to 'Housekeeping', housekeeping_namespace_project_path(@project.namespace, @project),
method: :post, class: "btn btn-save"
%hr
+ .row.prepend-top-default
+ .col-lg-3
+ %h4.prepend-top-0
+ Export project
+ %p.append-bottom-0
+ %p
+ Generates a compressed export file of the project and sends a link to download the export.
+ .col-lg-9
+
+ = link_to 'Generate new export', export_namespace_project_path(@project.namespace, @project),
+ method: :post, class: "btn btn-default"
+
+ %hr
- if can? current_user, :archive_project, @project
.row.prepend-top-default
.col-lg-3
diff --git a/app/workers/project_import_worker.rb b/app/workers/project_import_worker.rb
index b2902c3278e..b18d453702e 100644
--- a/app/workers/project_import_worker.rb
+++ b/app/workers/project_import_worker.rb
@@ -7,10 +7,10 @@ class ProjectImportWorker
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,
- namespace_id: namespace_id,
- project_path: path)
+ project = Gitlab::ImportExport::Importer.execute(archive_file: tmp_file,
+ owner: current_user,
+ namespace_id: namespace_id,
+ project_path: path)
if project
project.repository.after_import
else