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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
c0403234
Commit
c0403234
authored
Jan 21, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Gitlab::BitbucketImport::KeyDeleter to it's own importer
parent
6dd88e09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
22 deletions
+29
-22
app/services/projects/import_service.rb
app/services/projects/import_service.rb
+0
-4
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+29
-18
No files found.
app/services/projects/import_service.rb
View file @
c0403234
...
@@ -49,10 +49,6 @@ module Projects
...
@@ -49,10 +49,6 @@ module Projects
unless
importer
.
execute
unless
importer
.
execute
raise
Error
,
'The remote data could not be imported.'
raise
Error
,
'The remote data could not be imported.'
end
end
if
project
.
import_type
==
'bitbucket'
Gitlab
::
BitbucketImport
::
KeyDeleter
.
new
(
project
).
execute
end
end
end
def
has_importer?
def
has_importer?
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
c0403234
...
@@ -13,12 +13,34 @@ module Gitlab
...
@@ -13,12 +13,34 @@ module Gitlab
end
end
def
execute
def
execute
project_identifier
=
project
.
import_source
import_issues
if
has_issues?
return
true
unless
client
.
project
(
project_identifier
)[
"has_issues"
]
true
ensure
Gitlab
::
BitbucketImport
::
KeyDeleter
.
new
(
project
).
execute
end
#Issues && Comments
private
issues
=
client
.
issues
(
project_identifier
)
def
gl_user_id
(
project
,
bitbucket_id
)
if
bitbucket_id
user
=
User
.
joins
(
:identities
).
find_by
(
"identities.extern_uid = ? AND identities.provider = 'bitbucket'"
,
bitbucket_id
.
to_s
)
(
user
&&
user
.
id
)
||
project
.
creator_id
else
project
.
creator_id
end
end
def
identifier
project
.
import_source
end
def
has_issues?
client
.
project
(
identifier
)[
"has_issues"
]
end
def
import_issues
issues
=
client
.
issues
(
identifier
)
issues
.
each
do
|
issue
|
issues
.
each
do
|
issue
|
body
=
''
body
=
''
...
@@ -33,7 +55,7 @@ module Gitlab
...
@@ -33,7 +55,7 @@ module Gitlab
body
=
@formatter
.
author_line
(
author
)
body
=
@formatter
.
author_line
(
author
)
body
+=
issue
[
"content"
]
body
+=
issue
[
"content"
]
comments
=
client
.
issue_comments
(
project_
identifier
,
issue
[
"local_id"
])
comments
=
client
.
issue_comments
(
identifier
,
issue
[
"local_id"
])
if
comments
.
any?
if
comments
.
any?
body
+=
@formatter
.
comments_header
body
+=
@formatter
.
comments_header
...
@@ -56,20 +78,9 @@ module Gitlab
...
@@ -56,20 +78,9 @@ module Gitlab
author_id:
gl_user_id
(
project
,
reporter
)
author_id:
gl_user_id
(
project
,
reporter
)
)
)
end
end
rescue
ActiveRecord
::
RecordInvalid
=>
e
tru
e
raise
Projects
::
ImportService
::
Error
,
e
.
messag
e
end
end
private
def
gl_user_id
(
project
,
bitbucket_id
)
if
bitbucket_id
user
=
User
.
joins
(
:identities
).
find_by
(
"identities.extern_uid = ? AND identities.provider = 'bitbucket'"
,
bitbucket_id
.
to_s
)
(
user
&&
user
.
id
)
||
project
.
creator_id
else
project
.
creator_id
end
end
end
end
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