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
00cd8642
Commit
00cd8642
authored
Dec 07, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BitBucket importer: import issues with labels
parent
bd3bd9bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
lib/bitbucket/representation/issue.rb
lib/bitbucket/representation/issue.rb
+4
-0
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+22
-0
No files found.
lib/bitbucket/representation/issue.rb
View file @
00cd8642
...
...
@@ -7,6 +7,10 @@ module Bitbucket
raw
[
'id'
]
end
def
kind
raw
[
'kind'
]
end
def
author
raw
.
dig
(
'reporter'
,
'username'
)
||
'Anonymous'
end
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
00cd8642
module
Gitlab
module
BitbucketImport
class
Importer
LABELS
=
[{
title:
'bug'
,
color:
'#FF0000'
},
{
title:
'enhancement'
,
color:
'#428BCA'
},
{
title:
'proposal'
,
color:
'#69D100'
},
{
title:
'task'
,
color:
'#7F8C8D'
}].
freeze
attr_reader
:project
,
:client
def
initialize
(
project
)
@project
=
project
@client
=
Bitbucket
::
Client
.
new
(
project
.
import_data
.
credentials
)
@formatter
=
Gitlab
::
ImportFormatter
.
new
@labels
=
{}
end
def
execute
...
...
@@ -34,10 +40,14 @@ module Gitlab
def
import_issues
return
unless
repo
.
issues_enabled?
create_labels
client
.
issues
(
repo
).
each
do
|
issue
|
description
=
@formatter
.
author_line
(
issue
.
author
)
description
+=
issue
.
description
label_name
=
issue
.
kind
issue
=
project
.
issues
.
create
(
iid:
issue
.
iid
,
title:
issue
.
title
,
...
...
@@ -48,6 +58,8 @@ module Gitlab
updated_at:
issue
.
updated_at
)
assign_label
(
issue
,
label_name
)
if
issue
.
persisted?
client
.
issue_comments
(
repo
,
issue
.
iid
).
each
do
|
comment
|
# The note can be blank for issue service messages like "Changed title: ..."
...
...
@@ -74,6 +86,16 @@ module Gitlab
Rails
.
logger
.
error
(
"Bitbucket importer ERROR in
#{
project
.
path_with_namespace
}
: Couldn't import record properly
#{
e
.
message
}
"
)
end
def
create_labels
LABELS
.
each
do
|
label
|
@labels
[
label
[
:title
]]
=
project
.
labels
.
create!
(
label
)
end
end
def
assign_label
(
issue
,
label_name
)
issue
.
labels
<<
@labels
[
label_name
]
end
def
import_pull_requests
pull_requests
=
client
.
pull_requests
(
repo
)
...
...
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