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
1f2ecd84
Commit
1f2ecd84
authored
Aug 29, 2019
by
Sean Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor for code readability
parent
00eec9ca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
ee/app/services/merge_trains/refresh_merge_request_service.rb
...pp/services/merge_trains/refresh_merge_request_service.rb
+15
-15
No files found.
ee/app/services/merge_trains/refresh_merge_request_service.rb
View file @
1f2ecd84
...
...
@@ -14,7 +14,7 @@ module MergeTrains
@merge_request
=
merge_request
validate!
pipeline_created
=
create_
or_replace_pipeline
pipeline_created
=
create_
pipeline!
if
should_create_pipeline?
merge!
if
should_merge?
success
(
pipeline_created:
pipeline_created
.
present?
)
...
...
@@ -24,18 +24,6 @@ module MergeTrains
private
def
create_or_replace_pipeline
if
should_create_pipeline?
previous_pipeline
=
pipeline_for_merge_train
pipeline_created
=
create_pipeline!
if
previous_pipeline
&
.
reload
&
.
active?
previous_pipeline
.
auto_cancel_running
(
pipeline_created
)
end
end
pipeline_created
end
def
validate!
unless
project
.
merge_trains_enabled?
raise
ProcessError
,
'project disabled merge trains'
...
...
@@ -77,8 +65,8 @@ module MergeTrains
raise
ProcessError
,
result
[
:message
]
unless
result
[
:status
]
==
:success
merge_train
.
update!
(
pipeline:
result
[
:pipeline
])
result
[
:pipeline
]
cancel_pipeline_for_merge_train
(
result
[
:pipeline
])
update_pipeline_for_merge_train
(
result
[
:pipeline
])
end
def
should_merge?
...
...
@@ -125,6 +113,18 @@ module MergeTrains
merge_train
.
pipeline
end
def
cancel_pipeline_for_merge_train
(
new_pipeline
)
pipeline_for_merge_train
&
.
auto_cancel_running
(
new_pipeline
)
rescue
ActiveRecord
::
StaleObjectError
# Often the pipeline has already been canceled by the default cancelaltion
# mechanizm `Ci::CreatePipelineService#cancel_pending_pipelines`. In this
# case, we can ignore the exception as it's already canceled.
end
def
update_pipeline_for_merge_train
(
pipeline
)
merge_train
.
update!
(
pipeline:
pipeline
)
end
def
merge_user
merge_request
.
merge_user
end
...
...
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