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
Boxiang Sun
gitlab-ce
Commits
7462a8f9
Commit
7462a8f9
authored
Apr 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply GitHub labels to Issue/Merge Request that were imported
parent
05a4f444
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+14
-0
No files found.
lib/gitlab/github_import/importer.rb
View file @
7462a8f9
...
...
@@ -43,6 +43,7 @@ module Gitlab
if
gh_issue
.
valid?
issue
=
Issue
.
create!
(
gh_issue
.
attributes
)
apply_labels
(
gh_issue
.
number
,
issue
)
if
gh_issue
.
has_comments?
import_comments
(
gh_issue
.
number
,
issue
)
...
...
@@ -65,6 +66,7 @@ module Gitlab
merge_request
=
MergeRequest
.
new
(
pull_request
.
attributes
)
if
merge_request
.
save
apply_labels
(
pull_request
.
number
,
merge_request
)
import_comments
(
pull_request
.
number
,
merge_request
)
import_comments_on_diff
(
pull_request
.
number
,
merge_request
)
end
...
...
@@ -76,6 +78,18 @@ module Gitlab
raise
Projects
::
ImportService
::
Error
,
e
.
message
end
def
apply_labels
(
number
,
issuable
)
issue
=
client
.
issue
(
project
.
import_source
,
number
)
if
issue
.
labels
.
count
>
0
label_ids
=
issue
.
labels
.
map
do
|
raw
|
Label
.
find_by
(
LabelFormatter
.
new
(
project
,
raw
).
attributes
).
try
(
:id
)
end
issuable
.
update_attribute
(
:label_ids
,
label_ids
)
end
end
def
import_comments
(
issue_number
,
noteable
)
comments
=
client
.
issue_comments
(
project
.
import_source
,
issue_number
)
create_comments
(
comments
,
noteable
)
...
...
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