2014-01-24 07:18:32 -05:00
|
|
|
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
|
2015-01-06 19:24:47 -05:00
|
|
|
def execute(merge_request, commit_message)
|
2014-06-26 08:09:17 -04:00
|
|
|
merge_request.lock_mr
|
2014-01-24 07:18:32 -05:00
|
|
|
|
|
|
|
if Gitlab::Satellite::MergeAction.new(current_user, merge_request).merge!(commit_message)
|
|
|
|
merge_request.merge
|
|
|
|
|
2014-03-25 08:01:52 -04:00
|
|
|
create_merge_event(merge_request, current_user)
|
2015-01-06 19:24:47 -05:00
|
|
|
create_note(merge_request)
|
2015-01-26 01:49:05 -05:00
|
|
|
notification_service.merge_mr(merge_request, current_user)
|
2015-01-06 19:24:47 -05:00
|
|
|
execute_hooks(merge_request)
|
2014-01-24 07:18:32 -05:00
|
|
|
|
|
|
|
true
|
|
|
|
else
|
2014-06-26 08:09:17 -04:00
|
|
|
merge_request.unlock_mr
|
2014-01-24 07:18:32 -05:00
|
|
|
false
|
|
|
|
end
|
|
|
|
rescue
|
2014-06-26 08:09:17 -04:00
|
|
|
merge_request.unlock_mr if merge_request.locked?
|
2014-01-24 07:18:32 -05:00
|
|
|
merge_request.mark_as_unmergeable
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|