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
05a4f444
Commit
05a4f444
authored
Apr 17, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import labels from GitHub
parent
5f39729c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
1 deletion
+53
-1
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+11
-1
lib/gitlab/github_import/label_formatter.rb
lib/gitlab/github_import/label_formatter.rb
+23
-0
spec/lib/gitlab/github_import/label_formatter_spec.rb
spec/lib/gitlab/github_import/label_formatter_spec.rb
+19
-0
No files found.
lib/gitlab/github_import/importer.rb
View file @
05a4f444
...
...
@@ -16,7 +16,7 @@ module Gitlab
end
def
execute
import_issues
&&
import_pull_requests
&&
import_wiki
import_
labels
&&
import_
issues
&&
import_pull_requests
&&
import_wiki
end
private
...
...
@@ -25,6 +25,16 @@ module Gitlab
@import_data_credentials
||=
project
.
import_data
.
credentials
if
project
.
import_data
end
def
import_labels
client
.
labels
(
project
.
import_source
).
each
do
|
raw_data
|
Label
.
create!
(
LabelFormatter
.
new
(
project
,
raw_data
).
attributes
)
end
true
rescue
ActiveRecord
::
RecordInvalid
=>
e
raise
Projects
::
ImportService
::
Error
,
e
.
message
end
def
import_issues
client
.
list_issues
(
project
.
import_source
,
state: :all
,
sort: :created
,
...
...
lib/gitlab/github_import/label_formatter.rb
0 → 100644
View file @
05a4f444
module
Gitlab
module
GithubImport
class
LabelFormatter
<
BaseFormatter
def
attributes
{
project:
project
,
title:
title
,
color:
color
}
end
private
def
color
"#
#{
raw_data
.
color
}
"
end
def
title
raw_data
.
name
end
end
end
end
spec/lib/gitlab/github_import/label_formatter_spec.rb
0 → 100644
View file @
05a4f444
require
'spec_helper'
describe
Gitlab
::
GithubImport
::
LabelFormatter
,
lib:
true
do
describe
'#attributes'
do
it
'returns formatted attributes'
do
project
=
create
(
:project
)
raw
=
double
(
name:
'improvements'
,
color:
'e6e6e6'
)
formatter
=
described_class
.
new
(
project
,
raw
)
expect
(
formatter
.
attributes
).
to
eq
({
project:
project
,
title:
'improvements'
,
color:
'#e6e6e6'
})
end
end
end
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