Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
30123910
Commit
30123910
authored
Jun 10, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cancel Auto Merge when target branch is changed
When target branch is updated, Auto Merge should be canceled.
parent
a0af3458
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
7 deletions
+26
-7
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+4
-0
app/services/merge_requests/close_service.rb
app/services/merge_requests/close_service.rb
+0
-4
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+3
-3
app/services/merge_requests/update_service.rb
app/services/merge_requests/update_service.rb
+2
-0
changelogs/unreleased/cancel-auto-merge-when-branch-is-changed.yml
...s/unreleased/cancel-auto-merge-when-branch-is-changed.yml
+5
-0
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+12
-0
No files found.
app/services/merge_requests/base_service.rb
View file @
30123910
...
...
@@ -68,6 +68,10 @@ module MergeRequests
!
merge_request
.
for_fork?
end
def
cancel_auto_merge
(
merge_request
)
AutoMergeService
.
new
(
project
,
current_user
).
cancel
(
merge_request
)
end
# Returns all origin and fork merge requests from `@project` satisfying passed arguments.
# rubocop: disable CodeReuse/ActiveRecord
def
merge_requests_for
(
source_branch
,
mr_states:
[
:opened
])
...
...
app/services/merge_requests/close_service.rb
View file @
30123910
...
...
@@ -34,9 +34,5 @@ module MergeRequests
merge_request_metrics_service
(
merge_request
).
close
(
close_event
)
end
end
def
cancel_auto_merge
(
merge_request
)
AutoMergeService
.
new
(
project
,
current_user
).
cancel
(
merge_request
)
end
end
end
app/services/merge_requests/refresh_service.rb
View file @
30123910
...
...
@@ -24,7 +24,7 @@ module MergeRequests
reload_merge_requests
outdate_suggestions
refresh_pipelines_on_merge_requests
cancel_auto_merge
cancel_auto_merge
s
mark_pending_todos_done
cache_merge_requests_closing_issues
...
...
@@ -142,9 +142,9 @@ module MergeRequests
end
end
def
cancel_auto_merge
def
cancel_auto_merge
s
merge_requests_for_source_branch
.
each
do
|
merge_request
|
AutoMergeService
.
new
(
project
,
current_user
).
cancel
(
merge_request
)
cancel_auto_merge
(
merge_request
)
end
end
...
...
app/services/merge_requests/update_service.rb
View file @
30123910
...
...
@@ -43,6 +43,8 @@ module MergeRequests
create_branch_change_note
(
merge_request
,
'target'
,
merge_request
.
previous_changes
[
'target_branch'
].
first
,
merge_request
.
target_branch
)
cancel_auto_merge
(
merge_request
)
end
if
merge_request
.
assignees
!=
old_assignees
...
...
changelogs/unreleased/cancel-auto-merge-when-branch-is-changed.yml
0 → 100644
View file @
30123910
---
title
:
Cancel Auto Merge when target branch is changed
merge_request
:
29416
author
:
type
:
fixed
spec/services/merge_requests/update_service_spec.rb
View file @
30123910
...
...
@@ -406,6 +406,18 @@ describe MergeRequests::UpdateService, :mailer do
expect
(
pending_todo
.
reload
).
to
be_done
end
end
context
'when auto merge is enabled and target branch changed'
do
before
do
AutoMergeService
.
new
(
project
,
user
).
execute
(
merge_request
,
AutoMergeService
::
STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS
)
update_merge_request
({
target_branch:
'target'
})
end
it
'marks pending todos as done'
do
expect
(
pending_todo
.
reload
).
to
be_done
end
end
end
context
'when the merge request is relabeled'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment