diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-13 19:30:02 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 14:58:26 -0200 |
commit | f008cdf218952556a0dc93962f55c0ff50733594 (patch) | |
tree | 925f2b875d33c14376e5eec5d1fda409cc4c42dc | |
parent | ed7591f7b8c55498e3e38be41cc049a92b9fe4a6 (diff) | |
download | gitlab-ce-f008cdf218952556a0dc93962f55c0ff50733594.tar.gz |
Remove Issuable#add_labels_by_names
-rw-r--r-- | app/models/concerns/issuable.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/fogbugz_import/importer.rb | 25 | ||||
-rw-r--r-- | lib/gitlab/google_code_import/importer.rb | 19 |
3 files changed, 18 insertions, 38 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 0b57e318662..76de927ceab 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -230,18 +230,6 @@ module Issuable labels.order('title ASC').pluck(:title) end - def add_labels_by_names(label_names, current_user) - available_labels = LabelsFinder.new(current_user, project_id: project.id).execute - - label_names.each do |label_name| - title = label_name.strip - label = available_labels.find_by(title: title) - label ||= project.labels.build(title: title, color: Label::DEFAULT_COLOR) - - self.labels << label - end - end - # Convert this Issuable class name to a format usable by Ability definitions # # Examples: diff --git a/lib/gitlab/fogbugz_import/importer.rb b/lib/gitlab/fogbugz_import/importer.rb index 1d6f97b99c7..9e926e2681a 100644 --- a/lib/gitlab/fogbugz_import/importer.rb +++ b/lib/gitlab/fogbugz_import/importer.rb @@ -122,25 +122,20 @@ module Gitlab author_id = user_info(bug['ixPersonOpenedBy'])[:gitlab_id] || project.creator_id issue = Issue.create!( - project_id: project.id, - title: bug['sTitle'], - description: body, - author_id: author_id, - assignee_id: assignee_id, - state: bug['fOpen'] == 'true' ? 'opened' : 'closed' + iid: bug['ixBug'], + project_id: project.id, + title: bug['sTitle'], + description: body, + author_id: author_id, + assignee_id: assignee_id, + state: bug['fOpen'] == 'true' ? 'opened' : 'closed', + created_at: date, + updated_at: DateTime.parse(bug['dtLastUpdated']) ) - issue.add_labels_by_names(labels, project.creator) - if issue.iid != bug['ixBug'] - issue.update_attribute(:iid, bug['ixBug']) - end + issue.update_attribute(:label_ids, project.labels.where(title: labels).pluck(:id)) import_issue_comments(issue, comments) - - issue.update_attribute(:created_at, date) - - last_update = DateTime.parse(bug['dtLastUpdated']) - issue.update_attribute(:updated_at, last_update) end end diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index 8d757da2264..79a0eaba1e8 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -92,19 +92,16 @@ module Gitlab end issue = Issue.create!( - project_id: project.id, - title: raw_issue["title"], - description: body, - author_id: project.creator_id, - assignee_id: assignee_id, - state: raw_issue["state"] == "closed" ? "closed" : "opened" + iid: raw_issue['id'], + project_id: project.id, + title: raw_issue['title'], + description: body, + author_id: project.creator_id, + assignee_id: assignee_id, + state: raw_issue['state'] == 'closed' ? 'closed' : 'opened' ) - issue.add_labels_by_names(labels, project.creator) - - if issue.iid != raw_issue["id"] - issue.update_attribute(:iid, raw_issue["id"]) - end + issue.update_attribute(:label_ids, project.labels.where(title: labels).pluck(:id)) import_issue_comments(issue, comments) end |