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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
84b0039d
Commit
84b0039d
authored
Nov 07, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix merge train is not refreshed on abort
This commit fixes the merge train bug that it's not refreshed on abort
parent
1686da10
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
7 deletions
+66
-7
changelogs/unreleased/fix-merge-train-is-not-refreshed-when-aborted.yml
...eleased/fix-merge-train-is-not-refreshed-when-aborted.yml
+5
-0
ee/app/services/auto_merge/merge_train_service.rb
ee/app/services/auto_merge/merge_train_service.rb
+7
-2
ee/app/services/merge_trains/refresh_merge_request_service.rb
...pp/services/merge_trains/refresh_merge_request_service.rb
+3
-3
ee/spec/features/merge_trains/two_merge_requests_on_train_spec.rb
...features/merge_trains/two_merge_requests_on_train_spec.rb
+23
-0
ee/spec/services/auto_merge/merge_train_service_spec.rb
ee/spec/services/auto_merge/merge_train_service_spec.rb
+27
-1
ee/spec/services/merge_trains/refresh_merge_request_service_spec.rb
...rvices/merge_trains/refresh_merge_request_service_spec.rb
+1
-1
No files found.
changelogs/unreleased/fix-merge-train-is-not-refreshed-when-aborted.yml
0 → 100644
View file @
84b0039d
---
title
:
Fix merge train is not refreshed when the system aborts/drops a merge request
merge_request
:
19763
author
:
type
:
fixed
ee/app/services/auto_merge/merge_train_service.rb
View file @
84b0039d
...
...
@@ -31,10 +31,15 @@ module AutoMerge
end
end
def
abort
(
merge_request
,
reason
)
super
do
def
abort
(
merge_request
,
reason
,
process_next:
true
)
# Before dropping a merge request from a merge train, get the next
# merge request in order to refresh it later.
next_merge_request
=
merge_request
.
merge_train
&
.
next
super
(
merge_request
,
reason
)
do
if
merge_request
.
merge_train
&
.
destroy
SystemNoteService
.
abort_merge_train
(
merge_request
,
project
,
current_user
,
reason
)
AutoMergeProcessWorker
.
perform_async
(
next_merge_request
.
id
)
if
next_merge_request
&&
process_next
end
end
end
...
...
ee/app/services/merge_trains/refresh_merge_request_service.rb
View file @
84b0039d
...
...
@@ -19,7 +19,7 @@ module MergeTrains
success
(
pipeline_created:
pipeline_created
.
present?
)
rescue
ProcessError
=>
e
drop
(
e
)
abort
(
e
)
end
private
...
...
@@ -159,9 +159,9 @@ module MergeTrains
params
[
:require_recreate
]
end
def
drop
(
error
)
def
abort
(
error
)
AutoMerge
::
MergeTrainService
.
new
(
project
,
merge_user
)
.
abort
(
merge_request
,
error
.
message
)
.
abort
(
merge_request
,
error
.
message
,
process_next:
false
)
error
(
error
.
message
)
end
...
...
ee/spec/features/merge_trains/two_merge_requests_on_train_spec.rb
View file @
84b0039d
...
...
@@ -174,6 +174,29 @@ describe 'Two merge requests on a merge train' do
end
end
context
'when merge request 1 got a new commit'
do
before
do
oldrev
=
project
.
repository
.
commit
(
'feature'
).
sha
create_file_in_repo
(
project
,
'refs/heads/feature'
,
'refs/heads/feature'
,
'test.txt'
,
'This is test'
)
newrev
=
project
.
repository
.
commit
(
'feature'
).
sha
MergeRequests
::
RefreshService
.
new
(
project
,
maintainer_1
)
.
execute
(
oldrev
,
newrev
,
'refs/heads/feature'
)
merge_request_1
.
reload
merge_request_2
.
reload
end
it_behaves_like
'drops merge request 1 from the merge train'
do
let
(
:system_note
)
do
'removed this merge request from the merge train because source branch was updated'
end
end
it_behaves_like
're-creates a pipeline for merge request 2'
do
let
(
:target_branch_sha
)
{
project
.
repository
.
commit
(
'refs/heads/master'
).
sha
}
end
end
context
'when merge request 1 is not mergeable'
do
before
do
merge_request_1
.
update!
(
title:
merge_request_1
.
wip_title
)
...
...
ee/spec/services/auto_merge/merge_train_service_spec.rb
View file @
84b0039d
...
...
@@ -159,7 +159,7 @@ describe AutoMerge::MergeTrainService do
end
describe
'#abort'
do
subject
{
service
.
abort
(
merge_request
,
'an error'
)
}
subject
{
service
.
abort
(
merge_request
,
'an error'
,
**
args
)
}
let!
(
:merge_request
)
do
create
(
:merge_request
,
:on_train
,
...
...
@@ -167,6 +167,8 @@ describe AutoMerge::MergeTrainService do
target_project:
project
,
target_branch:
'master'
)
end
let
(
:args
)
{
{}
}
it
'aborts auto merge on the merge request'
do
subject
...
...
@@ -186,6 +188,30 @@ describe AutoMerge::MergeTrainService do
subject
end
context
'when the other merge request is following the merge request'
do
let!
(
:merge_request_2
)
do
create
(
:merge_request
,
:on_train
,
source_project:
project
,
source_branch:
'signed-commits'
,
target_project:
project
,
target_branch:
'master'
)
end
it
'processes the next merge request on the train'
do
expect
(
AutoMergeProcessWorker
).
to
receive
(
:perform_async
).
with
(
merge_request_2
.
id
)
subject
end
context
'when process_next is false'
do
let
(
:args
)
{
{
process_next:
false
}
}
it
'does not process the next merge request on the train'
do
expect
(
AutoMergeProcessWorker
).
not_to
receive
(
:perform_async
)
subject
end
end
end
end
describe
'#available_for?'
do
...
...
ee/spec/services/merge_trains/refresh_merge_request_service_spec.rb
View file @
84b0039d
...
...
@@ -28,7 +28,7 @@ describe MergeTrains::RefreshMergeRequestService do
it
do
expect_next_instance_of
(
AutoMerge
::
MergeTrainService
)
do
|
service
|
expect
(
service
).
to
receive
(
:abort
).
with
(
merge_request
,
kind_of
(
String
))
expect
(
service
).
to
receive
(
:abort
).
with
(
merge_request
,
kind_of
(
String
)
,
hash_including
(
process_next:
false
)
)
end
subject
...
...
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