diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-12-16 17:11:04 -0200 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-12-16 17:11:54 -0200 |
commit | dbe2ac8ccc07f53669214eb954489a6cb233d4e9 (patch) | |
tree | 20e15901fb6ee505e19ee25ea4fe57045ac3bc92 | |
parent | 20e472d946d7cc4a2b9dd91264458b1c4ceb5ab6 (diff) | |
download | gitlab-ce-bitbucket-oauth2.tar.gz |
Fix rubucop offensesbitbucket-oauth2
-rw-r--r-- | lib/gitlab/bitbucket_import/importer.rb | 54 | ||||
-rw-r--r-- | spec/lib/bitbucket/representation/issue_spec.rb | 1 |
2 files changed, 27 insertions, 28 deletions
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index f3760640655..d5287c69e6e 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -60,8 +60,6 @@ module Gitlab create_labels - gitlab_issue = nil - client.issues(repo).each do |issue| begin description = '' @@ -87,31 +85,33 @@ module Gitlab gitlab_issue.labels << @labels[label_name] - if gitlab_issue.persisted? - client.issue_comments(repo, issue.iid).each do |comment| - # The note can be blank for issue service messages like "Changed title: ..." - # We would like to import those comments as well but there is no any - # specific parameter that would allow to process them, it's just an empty comment. - # To prevent our importer from just crashing or from creating useless empty comments - # we do this check. - next unless comment.note.present? - - note = '' - note += @formatter.author_line(comment.author) unless find_user_id(comment.author) - note += comment.note - - begin - gitlab_issue.notes.create!( - project: project, - note: note, - author_id: gitlab_user_id(project, comment.author), - created_at: comment.created_at, - updated_at: comment.updated_at - ) - rescue StandardError => e - errors << { type: :issue_comment, iid: issue.iid, errors: e.message } - end - end + import_issue_comments(issue, gitlab_issue) if gitlab_issue.persisted? + end + end + + def import_issue_comments(issue, gitlab_issue) + client.issue_comments(repo, issue.iid).each do |comment| + # The note can be blank for issue service messages like "Changed title: ..." + # We would like to import those comments as well but there is no any + # specific parameter that would allow to process them, it's just an empty comment. + # To prevent our importer from just crashing or from creating useless empty comments + # we do this check. + next unless comment.note.present? + + note = '' + note += @formatter.author_line(comment.author) unless find_user_id(comment.author) + note += comment.note + + begin + gitlab_issue.notes.create!( + project: project, + note: note, + author_id: gitlab_user_id(project, comment.author), + created_at: comment.created_at, + updated_at: comment.updated_at + ) + rescue StandardError => e + errors << { type: :issue_comment, iid: issue.iid, errors: e.message } end end end diff --git a/spec/lib/bitbucket/representation/issue_spec.rb b/spec/lib/bitbucket/representation/issue_spec.rb index 9a195bebd31..20f47224aa8 100644 --- a/spec/lib/bitbucket/representation/issue_spec.rb +++ b/spec/lib/bitbucket/representation/issue_spec.rb @@ -14,7 +14,6 @@ describe Bitbucket::Representation::Issue do 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 } |