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
Jérome Perrin
gitlab-ce
Commits
b12d6541
Commit
b12d6541
authored
Dec 07, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BitBuckpet importer. Refactoring. Iteration 2
parent
67b7637e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
20 deletions
+18
-20
app/controllers/import/bitbucket_controller.rb
app/controllers/import/bitbucket_controller.rb
+1
-1
lib/bitbucket/client.rb
lib/bitbucket/client.rb
+2
-4
lib/bitbucket/page.rb
lib/bitbucket/page.rb
+2
-4
lib/bitbucket/paginator.rb
lib/bitbucket/paginator.rb
+2
-2
lib/bitbucket/representation/base.rb
lib/bitbucket/representation/base.rb
+4
-0
lib/bitbucket/representation/url.rb
lib/bitbucket/representation/url.rb
+0
-9
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+7
-0
No files found.
app/controllers/import/bitbucket_controller.rb
View file @
b12d6541
...
...
@@ -62,7 +62,7 @@ class Import::BitbucketController < Import::BaseController
end
def
provider
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
'bitbucket'
}
Gitlab
::
OAuth
::
Provider
.
config_for
(
'bitbucket'
)
end
def
options
...
...
lib/bitbucket/client.rb
View file @
b12d6541
...
...
@@ -13,11 +13,9 @@ module Bitbucket
def
issue_comments
(
repo
,
issue_id
)
path
=
"/repositories/
#{
repo
}
/issues/
#{
issue_id
}
/comments"
paginator
=
Paginator
.
new
(
connection
,
path
,
:
url
)
paginator
=
Paginator
.
new
(
connection
,
path
,
:
comment
)
Collection
.
new
(
paginator
).
map
do
|
comment_url
|
Representation
::
Comment
.
new
(
connection
.
get
(
comment_url
.
to_s
))
end
Collection
.
new
(
paginator
)
end
def
pull_requests
(
repo
)
...
...
lib/bitbucket/page.rb
View file @
b12d6541
...
...
@@ -18,14 +18,12 @@ module Bitbucket
private
def
parse_attrs
(
raw
)
attrs
=
%w(size page pagelen next previous)
attrs
.
map
{
|
attr
|
{
attr
.
to_sym
=>
raw
[
attr
]
}
}.
reduce
(
&
:merge
)
raw
.
slice
(
*
%w(size page pagelen next previous)
).
symbolize_keys
end
def
parse_values
(
raw
,
bitbucket_rep_class
)
return
[]
unless
raw
[
'values'
]
&&
raw
[
'values'
].
is_a?
(
Array
)
raw
[
'values'
].
map
{
|
hash
|
bitbucket_rep_class
.
new
(
hash
)
}
bitbucket_rep_class
.
decorate
(
raw
[
'values'
])
end
def
representation_class
(
type
)
...
...
lib/bitbucket/paginator.rb
View file @
b12d6541
...
...
@@ -26,12 +26,12 @@ module Bitbucket
page
.
nil?
||
page
.
next?
end
def
page
_url
def
next
_url
page
.
nil?
?
url
:
page
.
next
end
def
fetch_next_page
parsed_response
=
connection
.
get
(
page
_url
)
parsed_response
=
connection
.
get
(
next
_url
)
Page
.
new
(
parsed_response
,
type
)
end
end
...
...
lib/bitbucket/representation/base.rb
View file @
b12d6541
...
...
@@ -5,6 +5,10 @@ module Bitbucket
@raw
=
raw
end
def
self
.
decorate
(
entries
)
entries
.
map
{
|
entry
|
new
(
entry
)}
end
private
attr_reader
:raw
...
...
lib/bitbucket/representation/url.rb
deleted
100644 → 0
View file @
67b7637e
module
Bitbucket
module
Representation
class
Url
<
Representation
::
Base
def
to_s
raw
.
dig
(
'links'
,
'self'
,
'href'
)
end
end
end
end
lib/gitlab/bitbucket_import/importer.rb
View file @
b12d6541
...
...
@@ -50,6 +50,13 @@ module Gitlab
if
issue
.
persisted?
client
.
issue_comments
(
repo
,
issue
.
iid
).
each
do
|
comment
|
# The note can be blank for issue service messages like "Chenged title: ..."
# We would like to import those comments as well but there is no any
# specific parameter that would allow to process them, it's just an empty comment.
# To prevent our importer from just crashing or from creating useless empty comments
# we do this check.
next
unless
comment
.
note
.
present?
note
=
@formatter
.
author_line
(
comment
.
author
)
note
+=
comment
.
note
...
...
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