Commit cc773654 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Create services for issue close and reopen

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 0d41f6f0
...@@ -86,10 +86,9 @@ class GitPushService ...@@ -86,10 +86,9 @@ class GitPushService
author = commit_user(commit) author = commit_user(commit)
if !issues_to_close.empty? && is_default_branch if !issues_to_close.empty? && is_default_branch
Thread.current[:current_user] = author issues_to_close.each do |issue|
Thread.current[:current_commit] = commit Issues::CloseService.new(project, author, {}).execute(issue, commit)
end
issues_to_close.each { |i| i.close && i.save }
end end
# Create cross-reference notes for any other references. Omit any issues that were referenced in an # Create cross-reference notes for any other references. Omit any issues that were referenced in an
......
...@@ -3,11 +3,6 @@ module Issues ...@@ -3,11 +3,6 @@ module Issues
private private
# Create issue note with service comment like 'Status changed to closed'
def create_note(issue)
Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit)
end
def create_assignee_note(issue) def create_assignee_note(issue)
Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee) Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee)
end end
......
module Issues
class CloseService < BaseService
def execute(issue, commit = nil)
if issue.close
notification_service.close_issue(issue, current_user)
event_service.close_issue(issue, current_user)
create_note(issue, commit)
execute_hooks(issue)
end
issue
end
private
def create_note(issue, current_commit)
Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit)
end
end
end
module Issues
class ReopenService < BaseService
def execute(issue)
if issue.reopen
event_service.reopen_issue(issue, current_user)
create_note(issue, commit)
execute_hooks(issue)
end
issue
end
private
def create_note(issue)
Note.create_status_change_note(issue, issue.project, current_user, issue.state, nil)
end
end
end
...@@ -5,7 +5,7 @@ module Issues ...@@ -5,7 +5,7 @@ module Issues
issue.reset_events_cache issue.reset_events_cache
if issue.is_being_reassigned? if issue.is_being_reassigned?
notification.reassigned_issue(issue, current_user) notification_service.reassigned_issue(issue, current_user)
create_assignee_note(issue) create_assignee_note(issue)
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