mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 13:16:09 +10:00
Export project functionality This is a MR for the export functionality of https://gitlab.com/gitlab-org/gitlab-ce/issues/3050, which adds the ability to export single projects. - [x] members - DB data - [x] issues - [x] issue comments - [x] merge requests - [x] merge request diff - [x] merge request comments - [x] labels - [x] milestones - [x] snippets - [x] releases - [x] events - [x] commit statuses - [x] CI builds - File system data - [x] Git repository - [x] wiki - [x] uploads - [ ] ~~CI build traces~~ - [ ] ~~CI build artifacts~~ - [ ] ~~LFS objects~~ - DB configuration - [x] services - [x] web hooks - [x] protected branches - [x] deploy keys - [x] CI variables - [x] CI triggers See merge request !3114
49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
class Import::GitlabProjectsController < Import::BaseController
|
|
before_action :verify_gitlab_project_import_enabled
|
|
|
|
def new
|
|
@namespace_id = project_params[:namespace_id]
|
|
@namespace_name = Namespace.find(project_params[:namespace_id]).name
|
|
@path = project_params[:path]
|
|
end
|
|
|
|
def create
|
|
unless file_is_valid?
|
|
return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive." })
|
|
end
|
|
|
|
@project = Gitlab::ImportExport::ProjectCreator.new(project_params[:namespace_id],
|
|
current_user,
|
|
File.expand_path(project_params[:file].path),
|
|
project_params[:path]).execute
|
|
|
|
if @project.saved?
|
|
redirect_to(
|
|
project_path(@project),
|
|
notice: "Project '#{@project.name}' is being imported."
|
|
)
|
|
else
|
|
redirect_to(
|
|
new_import_gitlab_project_path,
|
|
alert: "Project could not be imported: #{@project.errors.full_messages.join(', ')}"
|
|
)
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def file_is_valid?
|
|
project_params[:file] && project_params[:file].respond_to?(:read)
|
|
end
|
|
|
|
def verify_gitlab_project_import_enabled
|
|
render_404 unless gitlab_project_import_enabled?
|
|
end
|
|
|
|
def project_params
|
|
params.permit(
|
|
:path, :namespace_id, :file
|
|
)
|
|
end
|
|
end
|