blob: cb8e531f0e133dab912a88965311956b837ecd9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# frozen_string_literal: true
module AutoMerge
class MergeWhenPipelineSucceedsService < AutoMerge::BaseService
def execute(merge_request)
super do
add_system_note(merge_request)
end
end
def process(merge_request)
logger.info("Processing Automerge")
return unless merge_request.actual_head_pipeline_success?
logger.info("Pipeline Success")
return unless merge_request.mergeable?
logger.info("Merge request mergeable")
merge_request.merge_async(merge_request.merge_user_id, merge_request.merge_params)
end
def cancel(merge_request)
super do
SystemNoteService.cancel_merge_when_pipeline_succeeds(merge_request, project, current_user)
end
end
def abort(merge_request, reason)
super do
SystemNoteService.abort_merge_when_pipeline_succeeds(merge_request, project, current_user, reason)
end
end
def available_for?(merge_request)
super do
check_availability(merge_request)
end
end
private
def add_system_note(merge_request)
SystemNoteService.merge_when_pipeline_succeeds(merge_request, project, current_user, merge_request.actual_head_pipeline.sha) if merge_request.saved_change_to_auto_merge_enabled?
end
def check_availability(merge_request)
merge_request.actual_head_pipeline&.active?
end
def notify(merge_request)
notification_service.async.merge_when_pipeline_succeeds(merge_request, current_user) if merge_request.saved_change_to_auto_merge_enabled?
end
def logger
@logger ||= Gitlab::AppLogger
end
end
end
|