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
57f11456
Commit
57f11456
authored
Mar 28, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport attached merge request pipelines
Backport changes to CE
parent
74ace2a4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
33 deletions
+11
-33
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+11
-9
spec/services/merge_requests/create_service_spec.rb
spec/services/merge_requests/create_service_spec.rb
+0
-13
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+0
-11
No files found.
app/services/merge_requests/base_service.rb
View file @
57f11456
...
@@ -55,15 +55,7 @@ module MergeRequests
...
@@ -55,15 +55,7 @@ module MergeRequests
end
end
def
create_pipeline_for
(
merge_request
,
user
)
def
create_pipeline_for
(
merge_request
,
user
)
return
unless
Feature
.
enabled?
(
:ci_merge_request_pipeline
,
return
unless
can_create_pipeline_for?
(
merge_request
)
merge_request
.
source_project
,
default_enabled:
true
)
##
# UpdateMergeRequestsWorker could be retried by an exception.
# MR pipelines should not be recreated in such case.
return
if
merge_request
.
merge_request_pipeline_exists?
return
if
merge_request
.
has_no_commits?
create_detached_merge_request_pipeline
(
merge_request
,
user
)
create_detached_merge_request_pipeline
(
merge_request
,
user
)
end
end
...
@@ -80,6 +72,16 @@ module MergeRequests
...
@@ -80,6 +72,16 @@ module MergeRequests
end
end
end
end
def
can_create_pipeline_for?
(
merge_request
)
##
# UpdateMergeRequestsWorker could be retried by an exception.
# pipelines for merge request should not be recreated in such case.
return
false
if
merge_request
.
merge_request_pipeline_exists?
return
false
if
merge_request
.
has_no_commits?
true
end
def
can_use_merge_request_ref?
(
merge_request
)
def
can_use_merge_request_ref?
(
merge_request
)
Feature
.
enabled?
(
:ci_use_merge_request_ref
,
project
,
default_enabled:
true
)
&&
Feature
.
enabled?
(
:ci_use_merge_request_ref
,
project
,
default_enabled:
true
)
&&
!
merge_request
.
for_fork?
!
merge_request
.
for_fork?
...
...
spec/services/merge_requests/create_service_spec.rb
View file @
57f11456
...
@@ -263,19 +263,6 @@ describe MergeRequests::CreateService do
...
@@ -263,19 +263,6 @@ describe MergeRequests::CreateService do
expect
(
merge_request
.
actual_head_pipeline
).
to
be_merge_request_event
expect
(
merge_request
.
actual_head_pipeline
).
to
be_merge_request_event
end
end
end
end
context
"when the 'ci_merge_request_pipeline' feature flag is disabled"
do
before
do
stub_feature_flags
(
ci_merge_request_pipeline:
false
)
end
it
'does not create a detached merge request pipeline'
do
expect
(
merge_request
).
to
be_persisted
merge_request
.
reload
expect
(
merge_request
.
merge_request_pipelines
.
count
).
to
eq
(
0
)
end
end
end
end
context
"when .gitlab-ci.yml does not have merge_requests keywords"
do
context
"when .gitlab-ci.yml does not have merge_requests keywords"
do
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
57f11456
...
@@ -230,17 +230,6 @@ describe MergeRequests::RefreshService do
...
@@ -230,17 +230,6 @@ describe MergeRequests::RefreshService do
end
.
not_to
change
{
@merge_request
.
merge_request_pipelines
.
count
}
end
.
not_to
change
{
@merge_request
.
merge_request_pipelines
.
count
}
end
end
end
end
context
"when the 'ci_merge_request_pipeline' feature flag is disabled"
do
before
do
stub_feature_flags
(
ci_merge_request_pipeline:
false
)
end
it
'does not create a detached merge request pipeline'
do
expect
{
subject
}
.
not_to
change
{
@merge_request
.
merge_request_pipelines
.
count
}
end
end
end
end
context
"when .gitlab-ci.yml does not have merge_requests keywords"
do
context
"when .gitlab-ci.yml does not have merge_requests keywords"
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