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
67b7637e
Commit
67b7637e
authored
Dec 07, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply review comments. Iteration 1
parent
43b7b0ce
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
29 deletions
+26
-29
lib/bitbucket/client.rb
lib/bitbucket/client.rb
+14
-15
lib/bitbucket/connection.rb
lib/bitbucket/connection.rb
+4
-4
lib/bitbucket/paginator.rb
lib/bitbucket/paginator.rb
+1
-1
lib/bitbucket/representation/issue.rb
lib/bitbucket/representation/issue.rb
+1
-5
lib/bitbucket/representation/pull_request_comment.rb
lib/bitbucket/representation/pull_request_comment.rb
+1
-1
lib/bitbucket/representation/repo.rb
lib/bitbucket/representation/repo.rb
+4
-2
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+1
-1
No files found.
lib/bitbucket/client.rb
View file @
67b7637e
...
@@ -5,40 +5,39 @@ module Bitbucket
...
@@ -5,40 +5,39 @@ module Bitbucket
end
end
def
issues
(
repo
)
def
issues
(
repo
)
relative_
path
=
"/repositories/
#{
repo
}
/issues"
path
=
"/repositories/
#{
repo
}
/issues"
paginator
=
Paginator
.
new
(
connection
,
relative_
path
,
:issue
)
paginator
=
Paginator
.
new
(
connection
,
path
,
:issue
)
Collection
.
new
(
paginator
)
Collection
.
new
(
paginator
)
end
end
def
issue_comments
(
repo
,
number
)
def
issue_comments
(
repo
,
issue_id
)
relative_path
=
"/repositories/
#{
repo
}
/issues/
#{
number
}
/comments"
path
=
"/repositories/
#{
repo
}
/issues/
#{
issue_id
}
/comments"
paginator
=
Paginator
.
new
(
connection
,
relative_
path
,
:url
)
paginator
=
Paginator
.
new
(
connection
,
path
,
:url
)
Collection
.
new
(
paginator
).
map
do
|
comment_url
|
Collection
.
new
(
paginator
).
map
do
|
comment_url
|
parsed_response
=
connection
.
get
(
comment_url
.
to_s
)
Representation
::
Comment
.
new
(
connection
.
get
(
comment_url
.
to_s
))
Representation
::
Comment
.
new
(
parsed_response
)
end
end
end
end
def
pull_requests
(
repo
)
def
pull_requests
(
repo
)
relative_
path
=
"/repositories/
#{
repo
}
/pullrequests?state=ALL"
path
=
"/repositories/
#{
repo
}
/pullrequests?state=ALL"
paginator
=
Paginator
.
new
(
connection
,
relative_
path
,
:pull_request
)
paginator
=
Paginator
.
new
(
connection
,
path
,
:pull_request
)
Collection
.
new
(
paginator
)
Collection
.
new
(
paginator
)
end
end
def
pull_request_comments
(
repo
,
pull_request
)
def
pull_request_comments
(
repo
,
pull_request
)
relative_
path
=
"/repositories/
#{
repo
}
/pullrequests/
#{
pull_request
}
/comments"
path
=
"/repositories/
#{
repo
}
/pullrequests/
#{
pull_request
}
/comments"
paginator
=
Paginator
.
new
(
connection
,
relative_
path
,
:pull_request_comment
)
paginator
=
Paginator
.
new
(
connection
,
path
,
:pull_request_comment
)
Collection
.
new
(
paginator
)
Collection
.
new
(
paginator
)
end
end
def
pull_request_diff
(
repo
,
pull_request
)
def
pull_request_diff
(
repo
,
pull_request
)
relative_
path
=
"/repositories/
#{
repo
}
/pullrequests/
#{
pull_request
}
/diff"
path
=
"/repositories/
#{
repo
}
/pullrequests/
#{
pull_request
}
/diff"
connection
.
get
(
relative_
path
)
connection
.
get
(
path
)
end
end
def
repo
(
name
)
def
repo
(
name
)
...
@@ -47,8 +46,8 @@ module Bitbucket
...
@@ -47,8 +46,8 @@ module Bitbucket
end
end
def
repos
def
repos
relative_
path
=
"/repositories/
#{
user
.
username
}
"
path
=
"/repositories/
#{
user
.
username
}
"
paginator
=
Paginator
.
new
(
connection
,
relative_
path
,
:repo
)
paginator
=
Paginator
.
new
(
connection
,
path
,
:repo
)
Collection
.
new
(
paginator
)
Collection
.
new
(
paginator
)
end
end
...
...
lib/bitbucket/connection.rb
View file @
67b7637e
...
@@ -5,8 +5,8 @@ module Bitbucket
...
@@ -5,8 +5,8 @@ module Bitbucket
DEFAULT_QUERY
=
{}
DEFAULT_QUERY
=
{}
def
initialize
(
options
=
{})
def
initialize
(
options
=
{})
@api_version
=
options
.
fetch
(
:api_version
,
DEFAULT_API_VERSION
)
@api_version
=
options
.
fetch
(
:api_version
,
DEFAULT_API_VERSION
)
@base_uri
=
options
.
fetch
(
:base_uri
,
DEFAULT_BASE_URI
)
@base_uri
=
options
.
fetch
(
:base_uri
,
DEFAULT_BASE_URI
)
@default_query
=
options
.
fetch
(
:query
,
DEFAULT_QUERY
)
@default_query
=
options
.
fetch
(
:query
,
DEFAULT_QUERY
)
@token
=
options
[
:token
]
@token
=
options
[
:token
]
...
@@ -23,7 +23,7 @@ module Bitbucket
...
@@ -23,7 +23,7 @@ module Bitbucket
@connection
||=
OAuth2
::
AccessToken
.
new
(
client
,
@token
,
refresh_token:
@refresh_token
,
expires_at:
@expires_at
,
expires_in:
@expires_in
)
@connection
||=
OAuth2
::
AccessToken
.
new
(
client
,
@token
,
refresh_token:
@refresh_token
,
expires_at:
@expires_at
,
expires_in:
@expires_in
)
end
end
def
query
(
params
=
{})
def
set_default_query_parameters
(
params
=
{})
@default_query
.
merge!
(
params
)
@default_query
.
merge!
(
params
)
end
end
...
@@ -63,7 +63,7 @@ module Bitbucket
...
@@ -63,7 +63,7 @@ module Bitbucket
end
end
def
provider
def
provider
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
'bitbucket'
}
Gitlab
::
OAuth
::
Provider
.
config_for
(
'bitbucket'
)
end
end
def
options
def
options
...
...
lib/bitbucket/paginator.rb
View file @
67b7637e
...
@@ -8,7 +8,7 @@ module Bitbucket
...
@@ -8,7 +8,7 @@ module Bitbucket
@url
=
url
@url
=
url
@page
=
nil
@page
=
nil
connection
.
query
(
pagelen:
PAGE_LENGTH
,
sort: :created_on
)
connection
.
set_default_query_parameters
(
pagelen:
PAGE_LENGTH
,
sort: :created_on
)
end
end
def
next
def
next
...
...
lib/bitbucket/representation/issue.rb
View file @
67b7637e
...
@@ -8,7 +8,7 @@ module Bitbucket
...
@@ -8,7 +8,7 @@ module Bitbucket
end
end
def
author
def
author
r
eporter
.
fetch
(
'username'
,
'Anonymous'
)
r
aw
.
dig
(
'reporter'
,
'username'
)
||
'Anonymous'
end
end
def
description
def
description
...
@@ -40,10 +40,6 @@ module Bitbucket
...
@@ -40,10 +40,6 @@ module Bitbucket
def
closed?
def
closed?
CLOSED_STATUS
.
include?
(
raw
[
'state'
])
CLOSED_STATUS
.
include?
(
raw
[
'state'
])
end
end
def
reporter
raw
.
fetch
(
'reporter'
,
{})
end
end
end
end
end
end
end
lib/bitbucket/representation/pull_request_comment.rb
View file @
67b7637e
...
@@ -18,7 +18,7 @@ module Bitbucket
...
@@ -18,7 +18,7 @@ module Bitbucket
end
end
def
parent_id
def
parent_id
raw
.
fetch
(
'parent'
,
{}).
fetch
(
'id'
,
nil
)
raw
.
dig
(
'parent'
,
'id'
)
end
end
def
inline?
def
inline?
...
...
lib/bitbucket/representation/repo.rb
View file @
67b7637e
...
@@ -23,7 +23,9 @@ module Bitbucket
...
@@ -23,7 +23,9 @@ module Bitbucket
url
=
raw
[
'links'
][
'clone'
].
find
{
|
link
|
link
[
'name'
]
==
'https'
}.
fetch
(
'href'
)
url
=
raw
[
'links'
][
'clone'
].
find
{
|
link
|
link
[
'name'
]
==
'https'
}.
fetch
(
'href'
)
if
token
.
present?
if
token
.
present?
url
.
sub
(
/^[^\@]*/
,
"https://x-token-auth:
#{
token
}
"
)
clone_url
=
URI
::
parse
(
url
)
clone_url
.
user
=
"x-token-auth:
#{
token
}
"
clone_url
.
to_s
else
else
url
url
end
end
...
@@ -37,7 +39,7 @@ module Bitbucket
...
@@ -37,7 +39,7 @@ module Bitbucket
raw
[
'full_name'
]
raw
[
'full_name'
]
end
end
def
has_issues
?
def
issues_enabled
?
raw
[
'has_issues'
]
raw
[
'has_issues'
]
end
end
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
67b7637e
...
@@ -32,7 +32,7 @@ module Gitlab
...
@@ -32,7 +32,7 @@ module Gitlab
end
end
def
import_issues
def
import_issues
return
unless
repo
.
has_issues
?
return
unless
repo
.
issues_enabled
?
client
.
issues
(
repo
).
each
do
|
issue
|
client
.
issues
(
repo
).
each
do
|
issue
|
description
=
@formatter
.
author_line
(
issue
.
author
)
description
=
@formatter
.
author_line
(
issue
.
author
)
...
...
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