BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
903da377
Commit
903da377
authored
Jun 13, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP - starting refactoring import/export to use services
parent
f449eeb6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
8 deletions
+55
-8
gitlab_projects_controller.rb
app/controllers/import/gitlab_projects_controller.rb
+21
-4
new.html.haml
app/views/import/gitlab_projects/new.html.haml
+4
-1
status.html.haml
app/views/import/gitlab_projects/status.html.haml
+0
-0
project_creator.rb
lib/gitlab/gitlab_import/project_creator.rb
+1
-3
project_creator.rb
lib/gitlab/import_export/project_creator.rb
+29
-0
No files found.
app/controllers/import/gitlab_projects_controller.rb
View file @
903da377
...
...
@@ -2,24 +2,41 @@ class Import::GitlabProjectsController < Import::BaseController
before_action
:verify_gitlab_project_import_enabled
before_action
:verify_project_and_namespace_access
rescue_from
OAuth
::
Error
,
with: :gitlab_project_unauthorized
def
new
@namespace_id
=
project_params
[
:namespace_id
]
@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
=
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
])
redirect_to
dashboard_projects_path
@project
=
Gitlab
::
GitlabImport
::
ProjectCreator
.
new
(
repo
,
namespace
,
current_user
,
access_params
).
execute
flash
[
:notice
]
=
"The project import has been started."
if
@project
.
saved?
redirect_to
(
project_path
(
@project
),
notice:
"Project '
#{
@project
.
name
}
' is being imported."
)
else
render
'new'
end
end
private
def
file_is_valid?
params
[
:file
].
respond_to?
(
:read
)
&&
params
[
:file
].
content_type
==
'application/x-gzip'
end
def
verify_project_and_namespace_access
unless
namespace_access?
render_403
...
...
@@ -27,7 +44,7 @@ class Import::GitlabProjectsController < Import::BaseController
end
def
namespace_access?
c
urrent_user
.
can?
(
:create_projects
,
Namespace
.
find
(
project_params
[
:namespace_id
]))
c
an?
(
current_user
,
:create_projects
,
Namespace
.
find
(
project_params
[
:namespace_id
]))
end
def
verify_gitlab_project_import_enabled
...
...
app/views/import/gitlab_projects/new.html.haml
View file @
903da377
-
page_title
"GitLab Import"
-
header_title
"Projects"
,
root_path
%h3
.page-title
%i
.fa.fa-gitlab
=
icon
(
'gitlab'
)
Import projects from GitLab
%hr
=
form_tag
import_gitlab_project_path
,
class:
'form-horizontal'
,
multipart:
true
do
%p
Project will be imported to path
#{
@path
}
%p
To get started add your exported project file below:
.form-group
=
hidden_field_tag
:namespace_id
,
@namespace_id
...
...
app/views/import/gitlab_projects/status.html.haml
deleted
100644 → 0
View file @
f449eeb6
lib/gitlab/gitlab_import/project_creator.rb
View file @
903da377
...
...
@@ -11,7 +11,7 @@ module Gitlab
end
def
execute
project
=
::
Projects
::
CreateService
.
new
(
::
Projects
::
CreateService
.
new
(
current_user
,
name:
repo
[
"name"
],
path:
repo
[
"path"
],
...
...
@@ -22,8 +22,6 @@ module Gitlab
import_source:
repo
[
"path_with_namespace"
],
import_url:
repo
[
"http_url_to_repo"
].
sub
(
"://"
,
"://oauth2:
#{
@session_data
[
:gitlab_access_token
]
}
@"
)
).
execute
project
end
end
end
...
...
lib/gitlab/import_export/project_creator.rb
0 → 100644
View file @
903da377
module
Gitlab
module
ImportExport
class
ProjectCreator
def
initialize
(
namespace_id
,
current_user
,
)
@repo
=
repo
@namespace
=
Namespace
.
find_by_id
(
namespace_id
)
@current_user
=
current_user
@user_map
=
user_map
end
def
execute
::
Projects
::
CreateService
.
new
(
current_user
,
name:
repo
.
name
,
path:
repo
.
name
,
description:
repo
.
summary
,
namespace:
namespace
,
creator:
current_user
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
import_type:
"google_code"
,
import_source:
repo
.
name
,
import_url:
repo
.
import_url
,
import_data:
{
data:
{
'repo'
=>
repo
.
raw_data
,
'user_map'
=>
user_map
}
}
).
execute
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment