gitlab-org--gitlab-foss/app/services/merge_requests/auto_merge_service.rb
Jacob Vosmaer b5007c1565 Rename MergeRequest#lock! to #lock_mr!
As a warning from the StateMachine gem points out to us, there already
exists a method ActiveRecord#lock!. This change renames the `lock` and
`unlock` events defined on MergeRequest to `lock_mr` and `unlock_mr`.
2014-06-26 14:09:17 +02:00

29 lines
857 B
Ruby

module MergeRequests
# AutoMergeService class
#
# Do git merge in satellite and in case of success
# mark merge request as merged and execute all hooks and notifications
# Called when you do merge via GitLab UI
class AutoMergeService < BaseMergeService
def execute(merge_request, current_user, commit_message)
merge_request.lock_mr
if Gitlab::Satellite::MergeAction.new(current_user, merge_request).merge!(commit_message)
merge_request.merge
notification.merge_mr(merge_request, current_user)
create_merge_event(merge_request, current_user)
execute_project_hooks(merge_request)
true
else
merge_request.unlock_mr
false
end
rescue
merge_request.unlock_mr if merge_request.locked?
merge_request.mark_as_unmergeable
false
end
end
end