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
Léo-Paul Géneau
gitlab-ce
Commits
8f0cef0b
Commit
8f0cef0b
authored
Dec 14, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BB importer: Refactoring user importing logic[ci skip]
parent
f20ea1f5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
22 deletions
+14
-22
lib/bitbucket/representation/base.rb
lib/bitbucket/representation/base.rb
+0
-4
lib/bitbucket/representation/comment.rb
lib/bitbucket/representation/comment.rb
+1
-1
lib/bitbucket/representation/issue.rb
lib/bitbucket/representation/issue.rb
+1
-1
lib/bitbucket/representation/pull_request.rb
lib/bitbucket/representation/pull_request.rb
+1
-1
lib/bitbucket/representation/user.rb
lib/bitbucket/representation/user.rb
+1
-5
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+10
-10
No files found.
lib/bitbucket/representation/base.rb
View file @
8f0cef0b
...
@@ -5,10 +5,6 @@ module Bitbucket
...
@@ -5,10 +5,6 @@ module Bitbucket
@raw
=
raw
@raw
=
raw
end
end
def
user_representation
(
raw
)
User
.
new
(
raw
)
end
def
self
.
decorate
(
entries
)
def
self
.
decorate
(
entries
)
entries
.
map
{
|
entry
|
new
(
entry
)}
entries
.
map
{
|
entry
|
new
(
entry
)}
end
end
...
...
lib/bitbucket/representation/comment.rb
View file @
8f0cef0b
...
@@ -2,7 +2,7 @@ module Bitbucket
...
@@ -2,7 +2,7 @@ module Bitbucket
module
Representation
module
Representation
class
Comment
<
Representation
::
Base
class
Comment
<
Representation
::
Base
def
author
def
author
user
_representation
(
user
)
user
[
'username'
]
end
end
def
note
def
note
...
...
lib/bitbucket/representation/issue.rb
View file @
8f0cef0b
...
@@ -12,7 +12,7 @@ module Bitbucket
...
@@ -12,7 +12,7 @@ module Bitbucket
end
end
def
author
def
author
user_representation
(
raw
.
fetch
(
'reporter'
,
{})
)
raw
.
dig
(
'reporter'
,
'username'
)
end
end
def
description
def
description
...
...
lib/bitbucket/representation/pull_request.rb
View file @
8f0cef0b
...
@@ -2,7 +2,7 @@ module Bitbucket
...
@@ -2,7 +2,7 @@ module Bitbucket
module
Representation
module
Representation
class
PullRequest
<
Representation
::
Base
class
PullRequest
<
Representation
::
Base
def
author
def
author
user_representation
(
raw
.
fetch
(
'author'
,
{})
)
raw
.
dig
(
'author'
,
'username'
)
end
end
def
description
def
description
...
...
lib/bitbucket/representation/user.rb
View file @
8f0cef0b
...
@@ -2,11 +2,7 @@ module Bitbucket
...
@@ -2,11 +2,7 @@ module Bitbucket
module
Representation
module
Representation
class
User
<
Representation
::
Base
class
User
<
Representation
::
Base
def
username
def
username
raw
[
'username'
]
||
'Anonymous'
raw
[
'username'
]
end
def
uuid
raw
[
'uuid'
]
end
end
end
end
end
end
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
8f0cef0b
...
@@ -24,21 +24,21 @@ module Gitlab
...
@@ -24,21 +24,21 @@ module Gitlab
private
private
def
gitlab_user_id
(
project
,
user
)
def
gitlab_user_id
(
project
,
user
name
)
if
user
.
uuid
if
user
name
user
=
find_user
_by_uuid
(
user
.
uuid
)
user
=
find_user
(
username
)
(
user
&&
user
.
id
)
||
project
.
creator_id
(
user
&&
user
.
id
)
||
project
.
creator_id
else
else
project
.
creator_id
project
.
creator_id
end
end
end
end
def
find_user
_by_uuid
(
uuid
)
def
find_user
(
username
)
User
.
joins
(
:identities
).
find_by
(
"identities.extern_uid = ? AND identities.provider = 'bitbucket'"
,
u
uid
)
User
.
joins
(
:identities
).
find_by
(
"identities.extern_uid = ? AND identities.provider = 'bitbucket'"
,
u
sername
)
end
end
def
existing_gitlab_user?
(
user
)
def
existing_gitlab_user?
(
user
name
)
user
.
uuid
&&
find_user_by_uuid
(
user
.
uuid
)
user
name
&&
find_user
(
username
)
end
end
def
repo
def
repo
...
@@ -52,7 +52,7 @@ module Gitlab
...
@@ -52,7 +52,7 @@ module Gitlab
client
.
issues
(
repo
).
each
do
|
issue
|
client
.
issues
(
repo
).
each
do
|
issue
|
description
=
''
description
=
''
description
+=
@formatter
.
author_line
(
issue
.
author
.
username
)
unless
existing_gitlab_user?
(
issue
.
author
)
description
+=
@formatter
.
author_line
(
issue
.
author
)
unless
existing_gitlab_user?
(
issue
.
author
)
description
+=
issue
.
description
description
+=
issue
.
description
label_name
=
issue
.
kind
label_name
=
issue
.
kind
...
@@ -79,7 +79,7 @@ module Gitlab
...
@@ -79,7 +79,7 @@ module Gitlab
next
unless
comment
.
note
.
present?
next
unless
comment
.
note
.
present?
note
=
''
note
=
''
note
+=
@formatter
.
author_line
(
comment
.
author
.
username
)
unless
existing_gitlab_user?
(
comment
.
author
)
note
+=
@formatter
.
author_line
(
comment
.
author
)
unless
existing_gitlab_user?
(
comment
.
author
)
note
+=
comment
.
note
note
+=
comment
.
note
issue
.
notes
.
create!
(
issue
.
notes
.
create!
(
...
@@ -108,7 +108,7 @@ module Gitlab
...
@@ -108,7 +108,7 @@ module Gitlab
pull_requests
.
each
do
|
pull_request
|
pull_requests
.
each
do
|
pull_request
|
begin
begin
description
=
''
description
=
''
description
+=
@formatter
.
author_line
(
pull_request
.
author
.
username
)
unless
existing_gitlab_user?
(
pull_request
.
author
)
description
+=
@formatter
.
author_line
(
pull_request
.
author
)
unless
existing_gitlab_user?
(
pull_request
.
author
)
description
+=
pull_request
.
description
description
+=
pull_request
.
description
merge_request
=
project
.
merge_requests
.
create
(
merge_request
=
project
.
merge_requests
.
create
(
...
...
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