Commit fc18e96d authored by Rubén Dávila's avatar Rubén Dávila

Refactor creation of system notes for Issue/MR labels. #2296

parent 97afb84b
...@@ -53,15 +53,7 @@ class IssuableBaseService < BaseService ...@@ -53,15 +53,7 @@ class IssuableBaseService < BaseService
if params.present? && issuable.update_attributes(params.merge(updated_by: current_user)) if params.present? && issuable.update_attributes(params.merge(updated_by: current_user))
issuable.reset_events_cache issuable.reset_events_cache
handle_common_system_notes(issuable, old_labels: old_labels)
if issuable.labels != old_labels
create_labels_note(
issuable,
issuable.labels - old_labels,
old_labels - issuable.labels)
end
handle_common_system_notes(issuable)
handle_changes(issuable) handle_changes(issuable)
issuable.create_new_cross_references!(current_user) issuable.create_new_cross_references!(current_user)
execute_hooks(issuable, 'update') execute_hooks(issuable, 'update')
...@@ -79,7 +71,7 @@ class IssuableBaseService < BaseService ...@@ -79,7 +71,7 @@ class IssuableBaseService < BaseService
end end
end end
def handle_common_system_notes(issuable) def handle_common_system_notes(issuable, options = {})
if issuable.previous_changes.include?('title') if issuable.previous_changes.include?('title')
create_title_change_note(issuable, issuable.previous_changes['title'].first) create_title_change_note(issuable, issuable.previous_changes['title'].first)
end end
...@@ -87,5 +79,10 @@ class IssuableBaseService < BaseService ...@@ -87,5 +79,10 @@ class IssuableBaseService < BaseService
if issuable.previous_changes.include?('description') && issuable.tasks? if issuable.previous_changes.include?('description') && issuable.tasks?
create_task_status_note(issuable) create_task_status_note(issuable)
end end
old_labels = options[:old_labels]
if old_labels && (issuable.labels != old_labels)
create_labels_note(issuable, issuable.labels - old_labels, old_labels - issuable.labels)
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment