2014-09-02 18:07:02 +05:30
|
|
|
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-04-26 12:48:37 +05:30
|
|
|
def execute(merge_request, commit_message)
|
2014-09-02 18:07:02 +05:30
|
|
|
merge_request.lock_mr
|
|
|
|
|
|
|
|
if Gitlab::Satellite::MergeAction.new(current_user, merge_request).merge!(commit_message)
|
|
|
|
merge_request.merge
|
|
|
|
|
|
|
|
create_merge_event(merge_request, current_user)
|
2015-04-26 12:48:37 +05:30
|
|
|
create_note(merge_request)
|
|
|
|
notification_service.merge_mr(merge_request, current_user)
|
2015-09-11 14:41:01 +05:30
|
|
|
execute_hooks(merge_request, 'merge')
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
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
|