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
|
|
|
|
|
2015-11-26 14:37:03 +05:30
|
|
|
handle_changes(issue)
|
|
|
|
issue.create_new_cross_references!(current_user)
|
|
|
|
execute_hooks(issue, 'update')
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-11-26 14:37:03 +05:30
|
|
|
issue
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-11-26 14:37:03 +05:30
|
|
|
def handle_changes(issue)
|
|
|
|
if issue.previous_changes.include?('milestone_id')
|
|
|
|
create_milestone_note(issue)
|
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2015-11-26 14:37:03 +05:30
|
|
|
if issue.previous_changes.include?('assignee_id')
|
|
|
|
create_assignee_note(issue)
|
|
|
|
notification_service.reassigned_issue(issue, current_user)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-11-26 14:37:03 +05:30
|
|
|
if issue.previous_changes.include?('title')
|
|
|
|
create_title_change_note(issue, issue.previous_changes['title'].first)
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|