Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-07-26 15:21:53 +0300
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-07-28 12:32:46 +0300
commit1d3815f89b9b9f5ecfd6dd15158a2988603b9ed8 (patch)
treea694e1e05f58fc3fe5ae00135d4a439eef7c8150 /app/controllers
parentd964816b9fe56679ffc0b331e701f7b24db5c6a9 (diff)
Allow projects to be started from a template
Started implementation for the first iteration of gitlab-org/gitlab-ce#32420. This will allow users to select a template to start with, instead of an empty repository in the project just created. Internally this is basically a small extension of the ImportExport GitLab projects we already support. We just import a certain import tar archive. This commits includes the first one: Ruby on Rails. In the future more will be added.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/import/gitlab_projects_controller.rb10
-rw-r--r--app/controllers/projects_controller.rb12
2 files changed, 12 insertions, 10 deletions
diff --git a/app/controllers/import/gitlab_projects_controller.rb b/app/controllers/import/gitlab_projects_controller.rb
index 36d246d185b..6463d2dfd5b 100644
--- a/app/controllers/import/gitlab_projects_controller.rb
+++ b/app/controllers/import/gitlab_projects_controller.rb
@@ -12,15 +12,7 @@ class Import::GitlabProjectsController < Import::BaseController
return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive." })
end
- import_upload_path = Gitlab::ImportExport.import_upload_path(filename: project_params[:file].original_filename)
-
- FileUtils.mkdir_p(File.dirname(import_upload_path))
- FileUtils.copy_entry(project_params[:file].path, import_upload_path)
-
- @project = Gitlab::ImportExport::ProjectCreator.new(project_params[:namespace_id],
- current_user,
- import_upload_path,
- project_params[:path]).execute
+ @project = ::Projects::GitlabProjectsImporterService.new(current_user, project_params).execute
if @project.saved?
redirect_to(
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index c769693255c..275474d02f6 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -27,7 +27,12 @@ class ProjectsController < Projects::ApplicationController
end
def create
- @project = ::Projects::CreateService.new(current_user, project_params).execute
+ @project =
+ if project_from_template?
+ ::Projects::CreateFromTemplateService.new(current_user, project_params).execute
+ else
+ ::Projects::CreateService.new(current_user, project_params).execute
+ end
if @project.saved?
cookies[:issue_board_welcome_hidden] = { path: project_path(@project), value: nil, expires: Time.at(0) }
@@ -324,6 +329,7 @@ class ProjectsController < Projects::ApplicationController
:runners_token,
:tag_list,
:visibility_level,
+ :template_title,
project_feature_attributes: %i[
builds_access_level
@@ -345,6 +351,10 @@ class ProjectsController < Projects::ApplicationController
false
end
+ def project_from_template?
+ project_params[:template_title]&.present?
+ end
+
def project_view_files?
if current_user
current_user.project_view == 'files'