debian-mirror-gitlab/app/services/issues/update_service.rb

46 lines
1.4 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module Issues
class UpdateService < Issues::BaseService
def execute(issue)
2015-09-11 14:41:01 +05:30
case params.delete(:state_event)
2014-09-02 18:07:02 +05:30
when 'reopen'
Issues::ReopenService.new(project, current_user, {}).execute(issue)
when 'close'
Issues::CloseService.new(project, current_user, {}).execute(issue)
end
2015-04-26 12:48:37 +05:30
params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
2015-09-11 14:41:01 +05:30
filter_params
2015-04-26 12:48:37 +05:30
old_labels = issue.labels.to_a
2015-09-11 14:41:01 +05:30
if params.present? && issue.update_attributes(params.merge(updated_by: current_user))
2014-09-02 18:07:02 +05:30
issue.reset_events_cache
2015-04-26 12:48:37 +05:30
if issue.labels != old_labels
create_labels_note(
issue, issue.labels - old_labels, old_labels - issue.labels)
end
2014-09-02 18:07:02 +05:30
if issue.previous_changes.include?('milestone_id')
create_milestone_note(issue)
end
if issue.previous_changes.include?('assignee_id')
create_assignee_note(issue)
2015-04-26 12:48:37 +05:30
notification_service.reassigned_issue(issue, current_user)
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
if issue.previous_changes.include?('title')
create_title_change_note(issue, issue.previous_changes['title'].first)
end
issue.create_new_cross_references!(issue.project, current_user)
2014-09-02 18:07:02 +05:30
execute_hooks(issue, 'update')
end
issue
end
end
end