Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
10f16095
Commit
10f16095
authored
Apr 25, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes to be picked by the UI branch
parent
8f973b8f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
5 deletions
+66
-5
app/controllers/import/gitlab_project_controller.rb
app/controllers/import/gitlab_project_controller.rb
+46
-0
config/routes.rb
config/routes.rb
+6
-0
lib/gitlab/import_export/import_service.rb
lib/gitlab/import_export/import_service.rb
+14
-5
No files found.
app/controllers/import/gitlab_project_controller.rb
0 → 100644
View file @
10f16095
class
Import::GitlabProjectController
<
Import
::
BaseController
before_action
:verify_gitlab_project_import_enabled
before_action
:gitlab_project_auth
,
except: :callback
rescue_from
OAuth
::
Error
,
with: :gitlab_project_unauthorized
#TODO permissions stuff
def
callback
redirect_to
status_import_gitlab_project_url
end
def
status
@repos
=
client
.
projects
@incompatible_repos
=
client
.
incompatible_projects
@already_added_projects
=
current_user
.
created_projects
.
where
(
import_type:
"gitlab_project"
)
already_added_projects_names
=
@already_added_projects
.
pluck
(
:import_source
)
@repos
.
to_a
.
reject!
{
|
repo
|
already_added_projects_names
.
include?
"
#{
repo
[
"owner"
]
}
/
#{
repo
[
"slug"
]
}
"
}
end
def
jobs
jobs
=
current_user
.
created_projects
.
where
(
import_type:
"gitlab_project"
).
to_json
(
only:
[
:id
,
:import_status
])
render
json:
jobs
end
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
=
Gitlab
::
ImportExport
::
ImportService
.
execute
(
archive_file:
file
,
owner:
repo_owner
)
end
private
def
verify_gitlab_project_import_enabled
render_404
unless
gitlab_project_import_enabled?
end
end
config/routes.rb
View file @
10f16095
...
@@ -156,6 +156,12 @@ Rails.application.routes.draw do
...
@@ -156,6 +156,12 @@ Rails.application.routes.draw do
get
:new_user_map
,
path: :user_map
get
:new_user_map
,
path: :user_map
post
:create_user_map
,
path: :user_map
post
:create_user_map
,
path: :user_map
end
end
resource
:gitlab_project
,
only:
[
:create
,
:new
],
controller: :gitlab_projects
do
get
:status
get
:callback
get
:jobs
end
end
end
#
#
...
...
app/services/projects
/import_export/import_service.rb
→
lib/gitlab
/import_export/import_service.rb
View file @
10f16095
module
Projects
module
Gitlab
module
ImportExport
module
ImportExport
class
ExportService
<
BaseService
class
ImportService
def
execute
(
options
=
{})
archive_file
=
options
[
:archive_file
]
def
self
.
execute
(
*
args
)
Gitlab
::
ImportExport
::
Importer
.
import
(
archive_file:
archive_file
,
storage_path:
storage_path
)
new
(
args
).
execute
end
def
initialize
(
options
=
{})
@archive_file
=
options
[
:archive_file
]
@current_user
=
options
[
:owner
]
end
def
execute
Gitlab
::
ImportExport
::
Importer
.
import
(
archive_file:
@archive_file
,
storage_path:
storage_path
)
restore_project_tree
restore_project_tree
restore_repo
(
project_tree
.
project
)
restore_repo
(
project_tree
.
project
)
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