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
e39f0240
Commit
e39f0240
authored
Dec 13, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BB importer: Adding created_by only when used is not found[ci skip]
parent
0057ed1e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
10 deletions
+29
-10
lib/bitbucket/representation/base.rb
lib/bitbucket/representation/base.rb
+4
-0
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
+5
-1
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+17
-6
No files found.
lib/bitbucket/representation/base.rb
View file @
e39f0240
...
...
@@ -5,6 +5,10 @@ module Bitbucket
@raw
=
raw
end
def
user_representation
(
raw
)
User
.
new
(
raw
)
end
def
self
.
decorate
(
entries
)
entries
.
map
{
|
entry
|
new
(
entry
)}
end
...
...
lib/bitbucket/representation/comment.rb
View file @
e39f0240
...
...
@@ -2,7 +2,7 @@ module Bitbucket
module
Representation
class
Comment
<
Representation
::
Base
def
author
user
.
fetch
(
'username'
,
'Anonymous'
)
user
_representation
(
user
)
end
def
note
...
...
lib/bitbucket/representation/issue.rb
View file @
e39f0240
...
...
@@ -12,7 +12,7 @@ module Bitbucket
end
def
author
raw
.
dig
(
'reporter'
,
'username'
)
||
'Anonymous'
user_representation
(
raw
.
fetch
(
'reporter'
,
{}))
end
def
description
...
...
lib/bitbucket/representation/pull_request.rb
View file @
e39f0240
...
...
@@ -2,7 +2,7 @@ module Bitbucket
module
Representation
class
PullRequest
<
Representation
::
Base
def
author
raw
.
fetch
(
'author'
,
{}).
fetch
(
'username'
,
'Anonymous'
)
user_representation
(
raw
.
fetch
(
'author'
,
{})
)
end
def
description
...
...
lib/bitbucket/representation/user.rb
View file @
e39f0240
...
...
@@ -2,7 +2,11 @@ module Bitbucket
module
Representation
class
User
<
Representation
::
Base
def
username
raw
[
'username'
]
raw
[
'username'
]
||
'Anonymous'
end
def
uuid
raw
[
'uuid'
]
end
end
end
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
e39f0240
...
...
@@ -24,15 +24,23 @@ module Gitlab
private
def
gitlab_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
)
def
gitlab_user_id
(
project
,
user
)
if
user
.
uu
id
user
=
find_user_by_uuid
(
user
.
uuid
)
(
user
&&
user
.
id
)
||
project
.
creator_id
else
project
.
creator_id
end
end
def
find_user_by_uuid
(
uuid
)
User
.
joins
(
:identities
).
find_by
(
"identities.extern_uid = ? AND identities.provider = 'bitbucket'"
,
uuid
)
end
def
existing_gitlab_user?
(
user
)
user
.
uuid
&&
find_user_by_uuid
(
user
.
uuid
)
end
def
repo
@repo
||=
client
.
repo
(
project
.
import_source
)
end
...
...
@@ -43,7 +51,8 @@ module Gitlab
create_labels
client
.
issues
(
repo
).
each
do
|
issue
|
description
=
@formatter
.
author_line
(
issue
.
author
)
description
=
''
description
+=
@formatter
.
author_line
(
issue
.
author
.
username
)
unless
existing_gitlab_user?
(
issue
.
author
)
description
+=
issue
.
description
label_name
=
issue
.
kind
...
...
@@ -69,7 +78,8 @@ module Gitlab
# we do this check.
next
unless
comment
.
note
.
present?
note
=
@formatter
.
author_line
(
comment
.
author
)
note
=
''
note
+=
@formatter
.
author_line
(
comment
.
author
.
username
)
unless
existing_gitlab_user?
(
comment
.
author
)
note
+=
comment
.
note
issue
.
notes
.
create!
(
...
...
@@ -97,7 +107,8 @@ module Gitlab
pull_requests
.
each
do
|
pull_request
|
begin
description
=
@formatter
.
author_line
(
pull_request
.
author
)
description
=
''
description
+=
@formatter
.
author_line
(
pull_request
.
author
.
username
)
unless
existing_gitlab_user?
(
pull_request
.
author
)
description
+=
pull_request
.
description
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