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
cbbc42e0
Commit
cbbc42e0
authored
Apr 26, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding more UI changes, updated controller, worker and refactored import service
parent
1d4c3fa1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
20 deletions
+37
-20
gitlab_projects_controller.rb
app/controllers/import/gitlab_projects_controller.rb
+12
-5
project.rb
app/models/project.rb
+4
-4
new.html.haml
app/views/import/gitlab_projects/new.html.haml
+1
-1
project_import_worker.rb
app/workers/project_import_worker.rb
+6
-3
import_service.rb
lib/gitlab/import_export/import_service.rb
+13
-7
project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+1
-0
No files found.
app/controllers/import/gitlab_projects_controller.rb
View file @
cbbc42e0
...
@@ -7,7 +7,8 @@ class Import::GitlabProjectsController < Import::BaseController
...
@@ -7,7 +7,8 @@ class Import::GitlabProjectsController < Import::BaseController
#TODO permissions stuff
#TODO permissions stuff
def
new
def
new
@namespace_id
=
project_params
[
:namespace_id
]
@path
=
project_params
[
:path
]
end
end
def
status
def
status
...
@@ -27,14 +28,14 @@ class Import::GitlabProjectsController < Import::BaseController
...
@@ -27,14 +28,14 @@ class Import::GitlabProjectsController < Import::BaseController
def
create
def
create
file
=
params
[
:file
]
file
=
params
[
:file
]
# @project_name =
repo_owner
=
current_user
.
username
repo_owner
=
current_user
.
username
@target_namespace
=
params
[
:new_namespace
].
presence
||
repo_owner
@target_namespace
=
params
[
:new_namespace
].
presence
||
repo_owner
namespace
=
get_or_create_namespace
||
(
render
and
return
)
@project
=
Project
.
create_from_import_job
(
current_user_id:
current_user
.
id
,
tmp_file:
File
.
expand_path
(
file
.
path
),
@project
=
Project
.
create_from_import_job
(
current_user
.
id
,
File
.
expand_path
(
file
.
path
))
namespace_id:
@namespace_id
,
project_path:
@path
)
end
end
private
private
...
@@ -42,4 +43,10 @@ class Import::GitlabProjectsController < Import::BaseController
...
@@ -42,4 +43,10 @@ class Import::GitlabProjectsController < Import::BaseController
def
verify_gitlab_project_import_enabled
def
verify_gitlab_project_import_enabled
render_404
unless
gitlab_project_import_enabled?
render_404
unless
gitlab_project_import_enabled?
end
end
def
project_params
params
.
require
(
:project
).
permit
(
:path
,
:namespace_id
,
)
end
end
end
app/models/project.rb
View file @
cbbc42e0
...
@@ -360,13 +360,13 @@ class Project < ActiveRecord::Base
...
@@ -360,13 +360,13 @@ class Project < ActiveRecord::Base
where
(
id:
user
.
authorized_projects
.
select
(
:id
).
reorder
(
nil
))
where
(
id:
user
.
authorized_projects
.
select
(
:id
).
reorder
(
nil
))
end
end
def
create_from_import_job
(
current_user_id
:,
tmp_file
:)
def
create_from_import_job
(
current_user_id
:,
tmp_file
:
,
namespace_id
:,
project_path
:
)
job_id
=
ProjectImportWorker
.
perform_async
(
current_user_id
,
tmp_file
)
job_id
=
ProjectImportWorker
.
perform_async
(
current_user_id
,
tmp_file
,
namespace_id
,
project_path
)
if
job_id
if
job_id
Rails
.
logger
.
info
"Import job started for
#{
path_with_namespac
e
}
with job ID
#{
job_id
}
"
Rails
.
logger
.
info
"Import job started for
export
#{
tmp_fil
e
}
with job ID
#{
job_id
}
"
else
else
Rails
.
logger
.
error
"Import job failed to start for
#{
path_with_namespac
e
}
"
Rails
.
logger
.
error
"Import job failed to start for
#{
tmp_fil
e
}
"
end
end
end
end
end
end
...
...
app/views/import/gitlab_projects/new.html.haml
View file @
cbbc42e0
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
Import projects from FogBugz
Import projects from FogBugz
%hr
%hr
=
form_tag
import_gitlab_project_path
,
class:
'form-horizontal'
do
=
form_tag
import_gitlab_project_path
,
class:
'form-horizontal'
,
multipart:
true
do
%p
%p
To get started you add your project export file below.
To get started you add your project export file below.
.form-group
.form-group
...
...
app/workers/project_import_worker.rb
View file @
cbbc42e0
...
@@ -2,12 +2,15 @@ class ProjectImportWorker
...
@@ -2,12 +2,15 @@ class ProjectImportWorker
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
include
Gitlab
::
ShellAdapter
include
Gitlab
::
ShellAdapter
sidekiq_options
queue: :gitlab_shell
sidekiq_options
queue: :gitlab_shell
,
retry:
false
def
perform
(
current_user_id
,
tmp_file
)
def
perform
(
current_user_id
,
tmp_file
,
namespace_id
,
path
)
current_user
=
User
.
find
(
current_user_id
)
current_user
=
User
.
find
(
current_user_id
)
project
=
Gitlab
::
ImportExport
::
ImportService
.
execute
(
archive_file:
tmp_file
,
owner:
current_user
)
project
=
Gitlab
::
ImportExport
::
ImportService
.
execute
(
archive_file:
tmp_file
,
owner:
current_user
,
namespace_id:
namespace_id
,
project_path:
path
)
# TODO: Move this to import service
# TODO: Move this to import service
# if result[:status] == :error
# if result[:status] == :error
...
...
lib/gitlab/import_export/import_service.rb
View file @
cbbc42e0
...
@@ -6,15 +6,17 @@ module Gitlab
...
@@ -6,15 +6,17 @@ module Gitlab
new
(
args
).
execute
new
(
args
).
execute
end
end
def
initialize
(
options
=
{})
def
initialize
(
archive_file
:,
owner
:,
namespace_id
:,
project_path
:)
@archive_file
=
options
[
:archive_file
]
@archive_file
=
archive_file
@current_user
=
options
[
:owner
]
@current_user
=
owner
@namespace_path
=
Namespace
.
find
(
namespace_id
).
path
@project_path
=
project_path
end
end
def
execute
def
execute
Gitlab
::
ImportExport
::
Importer
.
import
(
archive_file:
@archive_file
,
storage_path:
storage_path
)
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
end
end
private
private
...
@@ -27,12 +29,16 @@ module Gitlab
...
@@ -27,12 +29,16 @@ module Gitlab
@project_tree
||=
Gitlab
::
ImportExport
::
ProjectTreeRestorer
.
new
(
path:
storage_path
,
user:
@current_user
)
@project_tree
||=
Gitlab
::
ImportExport
::
ProjectTreeRestorer
.
new
(
path:
storage_path
,
user:
@current_user
)
end
end
def
restore_repo
(
project
)
def
restore_repo
Gitlab
::
ImportExport
::
RepoRestorer
.
new
(
path:
storage_path
,
project:
project
).
restore
Gitlab
::
ImportExport
::
RepoRestorer
.
new
(
path:
storage_path
,
project:
project
_tree
.
project
).
restore
end
end
def
storage_path
def
storage_path
@storage_path
||=
Gitlab
::
ImportExport
.
export_path
(
relative_path:
project
.
path_with_namespace
)
@storage_path
||=
Gitlab
::
ImportExport
.
export_path
(
relative_path:
path_with_namespace
)
end
def
path_with_namespace
File
.
join
(
@namespace_path
,
@project_path
)
end
end
end
end
end
end
...
...
lib/gitlab/import_export/project_tree_restorer.rb
View file @
cbbc42e0
...
@@ -49,6 +49,7 @@ module Gitlab
...
@@ -49,6 +49,7 @@ module Gitlab
project
=
Gitlab
::
ImportExport
::
ProjectFactory
.
create
(
project
=
Gitlab
::
ImportExport
::
ProjectFactory
.
create
(
project_params:
project_params
,
user:
@user
)
project_params:
project_params
,
user:
@user
)
project
.
save
project
.
save
project
.
import_start
project
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