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
Tatuya Kamada
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
unless
importer
.
execute
raise
Error
,
'The remote data could not be imported.'
end
if
project
.
import_type
==
'bitbucket'
Gitlab
::
BitbucketImport
::
KeyDeleter
.
new
(
project
).
execute
end
end
def
has_importer?
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
c0403234
...
...
@@ -13,12 +13,34 @@ module Gitlab
end
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
issues
=
client
.
issues
(
project_identifier
)
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
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
|
body
=
''
...
...
@@ -33,7 +55,7 @@ module Gitlab
body
=
@formatter
.
author_line
(
author
)
body
+=
issue
[
"content"
]
comments
=
client
.
issue_comments
(
project_
identifier
,
issue
[
"local_id"
])
comments
=
client
.
issue_comments
(
identifier
,
issue
[
"local_id"
])
if
comments
.
any?
body
+=
@formatter
.
comments_header
...
...
@@ -56,20 +78,9 @@ module Gitlab
author_id:
gl_user_id
(
project
,
reporter
)
)
end
tru
e
rescue
ActiveRecord
::
RecordInvalid
=>
e
raise
Projects
::
ImportService
::
Error
,
e
.
messag
e
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
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