2018-07-17 12:50:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-13 10:11:10 -04:00
|
|
|
module MergeRequests
|
|
|
|
# MergeService class
|
|
|
|
#
|
|
|
|
# Do git fast-forward merge and in case of success
|
|
|
|
# mark merge request as merged and execute all hooks and notifications
|
|
|
|
# Executed when you do fast-forward merge via GitLab UI
|
|
|
|
#
|
|
|
|
class FfMergeService < MergeRequests::MergeService
|
|
|
|
private
|
|
|
|
|
|
|
|
def commit
|
2019-11-18 07:06:03 -05:00
|
|
|
ff_merge = repository.ff_merge(current_user,
|
|
|
|
source,
|
|
|
|
merge_request.target_branch,
|
|
|
|
merge_request: merge_request)
|
|
|
|
|
2020-06-30 14:09:13 -04:00
|
|
|
if merge_request.squash_on_merge?
|
2019-11-18 07:06:03 -05:00
|
|
|
merge_request.update_column(:squash_commit_sha, merge_request.in_progress_merge_commit_sha)
|
|
|
|
end
|
|
|
|
|
|
|
|
ff_merge
|
2018-06-11 06:42:09 -04:00
|
|
|
rescue Gitlab::Git::PreReceiveError => e
|
2020-07-31 17:10:12 -04:00
|
|
|
Gitlab::ErrorTracking.track_exception(e, pre_receive_message: e.raw_message, merge_request_id: merge_request&.id)
|
2017-09-13 10:11:10 -04:00
|
|
|
raise MergeError, e.message
|
|
|
|
rescue StandardError => e
|
|
|
|
raise MergeError, "Something went wrong during merge: #{e.message}"
|
|
|
|
ensure
|
2020-09-23 08:09:58 -04:00
|
|
|
merge_request.update_and_mark_in_progress_merge_commit_sha(nil)
|
2017-09-13 10:11:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|