diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-04-17 23:52:34 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-04-18 17:14:59 -0300 |
commit | 05a4f444c368593216ab335db93ca98ce2218e94 (patch) | |
tree | b6018ea6ad4be802031882746b45a19a80a63d1b /lib | |
parent | 5f39729c19fa22836686dab32fbcf7c34f32fd41 (diff) | |
download | gitlab-ce-05a4f444c368593216ab335db93ca98ce2218e94.tar.gz |
Import labels from GitHub
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/github_import/importer.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/github_import/label_formatter.rb | 23 |
2 files changed, 34 insertions, 1 deletions
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb index 0b1ed510229..e406a0283b9 100644 --- a/lib/gitlab/github_import/importer.rb +++ b/lib/gitlab/github_import/importer.rb @@ -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, diff --git a/lib/gitlab/github_import/label_formatter.rb b/lib/gitlab/github_import/label_formatter.rb new file mode 100644 index 00000000000..c2b9d40b511 --- /dev/null +++ b/lib/gitlab/github_import/label_formatter.rb @@ -0,0 +1,23 @@ +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 |