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
Kazuhiko Shiozaki
gitlab-ce
Commits
841a7c68
Commit
841a7c68
authored
Nov 11, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store and show reason why import failed.
parent
53117775
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
45 deletions
+65
-45
app/models/project.rb
app/models/project.rb
+6
-4
app/views/projects/imports/new.html.haml
app/views/projects/imports/new.html.haml
+8
-4
app/workers/repository_fork_worker.rb
app/workers/repository_fork_worker.rb
+6
-8
app/workers/repository_import_worker.rb
app/workers/repository_import_worker.rb
+41
-26
lib/gitlab/backend/shell.rb
lib/gitlab/backend/shell.rb
+4
-3
No files found.
app/models/project.rb
View file @
841a7c68
...
@@ -310,15 +310,17 @@ class Project < ActiveRecord::Base
...
@@ -310,15 +310,17 @@ class Project < ActiveRecord::Base
def
add_import_job
def
add_import_job
if
forked?
if
forked?
unless
RepositoryForkWorker
.
perform_async
(
id
,
forked_from_project
.
path_with_namespace
,
self
.
namespace
.
path
)
RepositoryForkWorker
.
perform_async
(
self
.
id
,
forked_from_project
.
path_with_namespace
,
self
.
namespace
.
path
)
import_fail
end
else
else
RepositoryImportWorker
.
perform_async
(
id
)
RepositoryImportWorker
.
perform_async
(
self
.
id
)
end
end
end
end
def
clear_import_data
def
clear_import_data
update
(
import_error:
nil
)
ProjectCacheWorker
.
perform_async
(
self
.
id
)
self
.
import_data
.
destroy
if
self
.
import_data
self
.
import_data
.
destroy
if
self
.
import_data
end
end
...
...
app/views/projects/imports/new.html.haml
View file @
841a7c68
-
page_title
"Import repository"
-
page_title
"Import repository"
%h3
.page-title
%h3
.page-title
-
if
@project
.
import_failed?
Import repository
Import failed. Retry?
-
else
Import repository
%hr
%hr
-
if
@project
.
import_failed?
.alert.alert-danger
%p
The repository could not be imported.
%pre
.prepend-top-10
:preserve
#{
@project
.
import_error
.
try
(
:strip
)
}
=
form_for
@project
,
url:
namespace_project_import_path
(
@project
.
namespace
,
@project
),
method: :post
,
html:
{
class:
'form-horizontal'
}
do
|
f
|
=
form_for
@project
,
url:
namespace_project_import_path
(
@project
.
namespace
,
@project
),
method: :post
,
html:
{
class:
'form-horizontal'
}
do
|
f
|
.form-group.import-url-data
.form-group.import-url-data
=
f
.
label
:import_url
,
class:
'control-label'
do
=
f
.
label
:import_url
,
class:
'control-label'
do
...
...
app/workers/repository_fork_worker.rb
View file @
841a7c68
...
@@ -13,22 +13,20 @@ class RepositoryForkWorker
...
@@ -13,22 +13,20 @@ class RepositoryForkWorker
end
end
result
=
gitlab_shell
.
fork_repository
(
source_path
,
target_path
)
result
=
gitlab_shell
.
fork_repository
(
source_path
,
target_path
)
unless
result
unless
result
logger
.
error
(
"Unable to fork project
#{
project_id
}
for repository
#{
source_path
}
->
#{
target_path
}
"
)
logger
.
error
(
"Unable to fork project
#{
project_id
}
for repository
#{
source_path
}
->
#{
target_path
}
"
)
project
.
update
(
import_error:
"The project could not be forked."
)
project
.
import_fail
project
.
import_fail
project
.
save
return
return
end
end
if
project
.
valid_repo?
unless
project
.
valid_repo?
ProjectCacheWorker
.
perform_async
(
project
.
id
)
project
.
import_finish
else
project
.
import_fail
logger
.
error
(
"Project
#{
id
}
had an invalid repository after fork"
)
logger
.
error
(
"Project
#{
id
}
had an invalid repository after fork"
)
project
.
update
(
import_error:
"The forked repository is invalid."
)
project
.
import_fail
return
end
end
project
.
save
project
.
import_finish
end
end
end
end
app/workers/repository_import_worker.rb
View file @
841a7c68
...
@@ -7,37 +7,52 @@ class RepositoryImportWorker
...
@@ -7,37 +7,52 @@ class RepositoryImportWorker
def
perform
(
project_id
)
def
perform
(
project_id
)
project
=
Project
.
find
(
project_id
)
project
=
Project
.
find
(
project_id
)
unless
project
.
import_url
==
Project
::
UNKNOWN_IMPORT_URL
if
project
.
import_url
==
Project
::
UNKNOWN_IMPORT_URL
import_result
=
gitlab_shell
.
send
(
:import_repository
,
# In this case, we only want to import issues, not a repository.
project
.
path_with_namespace
,
project
.
import_url
)
return
project
.
import_fail
unless
import_result
else
unless
project
.
create_repository
unless
project
.
create_repository
return
project
.
import_fail
project
.
update
(
import_error:
"The repository could not be created."
)
project
.
import_fail
return
end
else
begin
import_result
=
gitlab_shell
.
import_repository
(
project
.
path_with_namespace
,
project
.
import_url
)
rescue
Gitlab
::
Shell
::
Error
=>
e
project
.
update
(
import_error:
e
.
message
)
project
.
import_fail
return
end
end
end
end
data_import_result
=
case
project
.
import_type
data_import_result
=
when
'github'
case
project
.
import_type
Gitlab
::
GithubImport
::
Importer
.
new
(
project
).
execute
when
'github'
when
'gitlab'
Gitlab
::
GithubImport
::
Importer
.
new
(
project
).
execute
Gitlab
::
GitlabImport
::
Importer
.
new
(
project
).
execute
when
'gitlab'
when
'bitbucket'
Gitlab
::
GitlabImport
::
Importer
.
new
(
project
).
execute
Gitlab
::
BitbucketImport
::
Importer
.
new
(
project
).
execute
when
'bitbucket'
when
'google_code'
Gitlab
::
BitbucketImport
::
Importer
.
new
(
project
).
execute
Gitlab
::
GoogleCodeImport
::
Importer
.
new
(
project
).
execute
when
'google_code'
when
'fogbugz'
Gitlab
::
GoogleCodeImport
::
Importer
.
new
(
project
).
execute
Gitlab
::
FogbugzImport
::
Importer
.
new
(
project
).
execute
when
'fogbugz'
else
Gitlab
::
FogbugzImport
::
Importer
.
new
(
project
).
execute
true
else
end
true
return
project
.
import_fail
unless
data_import_result
end
Gitlab
::
BitbucketImport
::
KeyDeleter
.
new
(
project
).
execute
if
project
.
import_type
==
'bitbucket'
unless
data_import_result
project
.
update
(
import_error:
"The remote issue data could not be imported."
)
project
.
import_fail
return
end
if
project
.
import_type
==
'bitbucket'
Gitlab
::
BitbucketImport
::
KeyDeleter
.
new
(
project
).
execute
end
project
.
import_finish
project
.
import_finish
project
.
save
ProjectCacheWorker
.
perform_async
(
project
.
id
)
# Explicitly update mirror so that upstream remote is created and fetched
project
.
update_mirror
end
end
end
end
lib/gitlab/backend/shell.rb
View file @
841a7c68
module
Gitlab
module
Gitlab
class
Shell
class
Shell
class
AccessDenied
<
StandardError
;
end
class
Error
<
StandardError
;
end
class
KeyAdder
<
Struct
.
new
(
:io
)
class
KeyAdder
<
Struct
.
new
(
:io
)
def
add_key
(
id
,
key
)
def
add_key
(
id
,
key
)
...
@@ -36,8 +36,9 @@ module Gitlab
...
@@ -36,8 +36,9 @@ module Gitlab
# import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git")
# import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git")
#
#
def
import_repository
(
name
,
url
)
def
import_repository
(
name
,
url
)
Gitlab
::
Utils
.
system_silent
([
gitlab_shell_projects_path
,
'import-project'
,
output
,
status
=
Popen
::
popen
([
gitlab_shell_projects_path
,
'import-project'
,
"
#{
name
}
.git"
,
url
,
'240'
])
"
#{
name
}
.git"
,
url
,
'240'
])
raise
Error
,
output
unless
status
.
zero?
true
end
end
# Move repository
# Move repository
...
...
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