diff options
author | Valery Sizov <valery@gitlab.com> | 2016-12-16 12:12:53 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-12-16 12:12:53 +0200 |
commit | e0ef9dc83ebfe102aaf980495b14fd6a06a24fd1 (patch) | |
tree | f4df6996d0d3034b41a3162aedfab36c06dd1747 | |
parent | ffa35233573acd31725677547555598fc36072e0 (diff) | |
download | gitlab-ce-e0ef9dc83ebfe102aaf980495b14fd6a06a24fd1.tar.gz |
BB importer: Milestone importer
-rw-r--r-- | lib/bitbucket/representation/issue.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/bitbucket_import/importer.rb | 2 | ||||
-rw-r--r-- | spec/lib/bitbucket/representation/issue_spec.rb | 6 |
3 files changed, 12 insertions, 0 deletions
diff --git a/lib/bitbucket/representation/issue.rb b/lib/bitbucket/representation/issue.rb index ffe8a65d839..3af731753d1 100644 --- a/lib/bitbucket/representation/issue.rb +++ b/lib/bitbucket/representation/issue.rb @@ -27,6 +27,10 @@ module Bitbucket raw['title'] end + def milestone + raw.dig('milestone', 'name') + end + def created_at raw['created_on'] end diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index 567f2b314aa..53c95ea4079 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -67,6 +67,7 @@ module Gitlab description += issue.description label_name = issue.kind + milestone = issue.milestone ? project.milestones.find_or_create_by(title: issue.milestone) : nil issue = project.issues.create!( iid: issue.iid, @@ -74,6 +75,7 @@ module Gitlab description: description, state: issue.state, author_id: gitlab_user_id(project, issue.author), + milestone: milestone, created_at: issue.created_at, updated_at: issue.updated_at ) diff --git a/spec/lib/bitbucket/representation/issue_spec.rb b/spec/lib/bitbucket/representation/issue_spec.rb index e1f3419c77e..9a195bebd31 100644 --- a/spec/lib/bitbucket/representation/issue_spec.rb +++ b/spec/lib/bitbucket/representation/issue_spec.rb @@ -9,6 +9,12 @@ describe Bitbucket::Representation::Issue do it { expect(described_class.new('kind' => 'bug').kind).to eq('bug') } end + describe '#milestone' do + it { expect(described_class.new({ 'milestone' => { 'name' => '1.0' } }).milestone).to eq('1.0') } + it { expect(described_class.new({}).milestone).to be_nil } + end + + describe '#author' do it { expect(described_class.new({ 'reporter' => { 'username' => 'Ben' } }).author).to eq('Ben') } it { expect(described_class.new({}).author).to be_nil } |