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
Boxiang Sun
gitlab-ce
Commits
1d4c3fa1
Commit
1d4c3fa1
authored
Apr 26, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more refactoring, now using custom job for processing project imports
parent
28b0208e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
3 deletions
+36
-3
app/controllers/import/gitlab_projects_controller.rb
app/controllers/import/gitlab_projects_controller.rb
+2
-2
app/models/project.rb
app/models/project.rb
+10
-0
app/views/import/gitlab_projects/new.html.haml
app/views/import/gitlab_projects/new.html.haml
+1
-1
app/workers/project_import_worker.rb
app/workers/project_import_worker.rb
+22
-0
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/controllers/import/gitlab_projects_controller.rb
View file @
1d4c3fa1
...
...
@@ -26,7 +26,7 @@ class Import::GitlabProjectsController < Import::BaseController
end
def
create
@
file
=
params
[
:file
]
file
=
params
[
:file
]
# @project_name =
repo_owner
=
current_user
.
username
...
...
@@ -34,7 +34,7 @@ class Import::GitlabProjectsController < Import::BaseController
namespace
=
get_or_create_namespace
||
(
render
and
return
)
@project
=
Gitlab
::
ImportExport
::
ImportService
.
execute
(
archive_file:
file
,
owner:
repo_owner
)
@project
=
Project
.
create_from_import_job
(
current_user
.
id
,
File
.
expand_path
(
file
.
path
)
)
end
private
...
...
app/models/project.rb
View file @
1d4c3fa1
...
...
@@ -359,6 +359,16 @@ class Project < ActiveRecord::Base
def
visible_to_user
(
user
)
where
(
id:
user
.
authorized_projects
.
select
(
:id
).
reorder
(
nil
))
end
def
create_from_import_job
(
current_user_id
:,
tmp_file
:)
job_id
=
ProjectImportWorker
.
perform_async
(
current_user_id
,
tmp_file
)
if
job_id
Rails
.
logger
.
info
"Import job started for
#{
path_with_namespace
}
with job ID
#{
job_id
}
"
else
Rails
.
logger
.
error
"Import job failed to start for
#{
path_with_namespace
}
"
end
end
end
def
team
...
...
app/views/import/gitlab_projects/new.html.haml
View file @
1d4c3fa1
...
...
@@ -5,7 +5,7 @@
Import projects from FogBugz
%hr
=
form_tag
status_import_gitlab_project_url
,
class:
'form-horizontal'
do
=
form_tag
import_gitlab_project_path
,
class:
'form-horizontal'
do
%p
To get started you add your project export file below.
.form-group
...
...
app/workers/project_import_worker.rb
0 → 100644
View file @
1d4c3fa1
class
ProjectImportWorker
include
Sidekiq
::
Worker
include
Gitlab
::
ShellAdapter
sidekiq_options
queue: :gitlab_shell
def
perform
(
current_user_id
,
tmp_file
)
current_user
=
User
.
find
(
current_user_id
)
project
=
Gitlab
::
ImportExport
::
ImportService
.
execute
(
archive_file:
tmp_file
,
owner:
current_user
)
# TODO: Move this to import service
# if result[:status] == :error
# project.update(import_error: result[:message])
# project.import_fail
# return
# end
project
.
repository
.
after_import
project
.
import_finish
end
end
config/routes.rb
View file @
1d4c3fa1
...
...
@@ -159,6 +159,7 @@ Rails.application.routes.draw do
resource
:gitlab_project
,
only:
[
:create
,
:new
],
controller: :gitlab_projects
do
get
:status
post
:create
get
:jobs
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