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
98c0eb0f
Commit
98c0eb0f
authored
Dec 07, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BitBucket refactoring. Iteration 3
parent
b12d6541
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
21 deletions
+15
-21
lib/bitbucket/client.rb
lib/bitbucket/client.rb
+10
-16
lib/bitbucket/collection.rb
lib/bitbucket/collection.rb
+1
-1
lib/bitbucket/paginator.rb
lib/bitbucket/paginator.rb
+1
-1
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+3
-3
No files found.
lib/bitbucket/client.rb
View file @
98c0eb0f
...
...
@@ -6,35 +6,26 @@ module Bitbucket
def
issues
(
repo
)
path
=
"/repositories/
#{
repo
}
/issues"
paginator
=
Paginator
.
new
(
connection
,
path
,
:issue
)
Collection
.
new
(
paginator
)
get_collection
(
path
,
:issue
)
end
def
issue_comments
(
repo
,
issue_id
)
path
=
"/repositories/
#{
repo
}
/issues/
#{
issue_id
}
/comments"
paginator
=
Paginator
.
new
(
connection
,
path
,
:comment
)
Collection
.
new
(
paginator
)
get_collection
(
path
,
:comment
)
end
def
pull_requests
(
repo
)
path
=
"/repositories/
#{
repo
}
/pullrequests?state=ALL"
paginator
=
Paginator
.
new
(
connection
,
path
,
:pull_request
)
Collection
.
new
(
paginator
)
get_collection
(
path
,
:pull_request
)
end
def
pull_request_comments
(
repo
,
pull_request
)
path
=
"/repositories/
#{
repo
}
/pullrequests/
#{
pull_request
}
/comments"
paginator
=
Paginator
.
new
(
connection
,
path
,
:pull_request_comment
)
Collection
.
new
(
paginator
)
get_collection
(
path
,
:pull_request_comment
)
end
def
pull_request_diff
(
repo
,
pull_request
)
path
=
"/repositories/
#{
repo
}
/pullrequests/
#{
pull_request
}
/diff"
connection
.
get
(
path
)
end
...
...
@@ -45,9 +36,7 @@ module Bitbucket
def
repos
path
=
"/repositories/
#{
user
.
username
}
"
paginator
=
Paginator
.
new
(
connection
,
path
,
:repo
)
Collection
.
new
(
paginator
)
get_collection
(
path
,
:repo
)
end
def
user
...
...
@@ -60,5 +49,10 @@ module Bitbucket
private
attr_reader
:connection
def
get_collection
(
path
,
type
)
paginator
=
Paginator
.
new
(
connection
,
path
,
type
)
Collection
.
new
(
paginator
)
end
end
end
lib/bitbucket/collection.rb
View file @
98c0eb0f
...
...
@@ -3,7 +3,7 @@ module Bitbucket
def
initialize
(
paginator
)
super
()
do
|
yielder
|
loop
do
paginator
.
next
.
each
{
|
item
|
yielder
<<
item
}
paginator
.
items
.
each
{
|
item
|
yielder
<<
item
}
end
end
...
...
lib/bitbucket/paginator.rb
View file @
98c0eb0f
...
...
@@ -11,7 +11,7 @@ module Bitbucket
connection
.
set_default_query_parameters
(
pagelen:
PAGE_LENGTH
,
sort: :created_on
)
end
def
next
def
items
raise
StopIteration
unless
has_next_page?
@page
=
fetch_next_page
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
98c0eb0f
...
...
@@ -50,7 +50,7 @@ module Gitlab
if
issue
.
persisted?
client
.
issue_comments
(
repo
,
issue
.
iid
).
each
do
|
comment
|
# The note can be blank for issue service messages like "Ch
e
nged title: ..."
# The note can be blank for issue service messages like "Ch
a
nged 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
...
...
@@ -70,8 +70,8 @@ module Gitlab
end
end
end
rescue
ActiveRecord
::
RecordInvalid
nil
rescue
ActiveRecord
::
RecordInvalid
=>
e
Rails
.
logger
.
error
(
"Bitbucket importer ERROR in
#{
project
.
path_with_namespace
}
: Couldn't import record properly
#{
e
.
message
}
"
)
end
def
import_pull_requests
...
...
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