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
cd584108
Commit
cd584108
authored
Oct 06, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove support for branch-less builds in MWBS
See !6675#note_16580143
parent
9824a69c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
22 deletions
+11
-22
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+10
-10
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
.../merge_requests/merge_when_build_succeeds_service_spec.rb
+1
-12
No files found.
app/services/merge_requests/base_service.rb
View file @
cd584108
...
...
@@ -42,20 +42,19 @@ module MergeRequests
super
(
:merge_request
)
end
def
merge_requests_for
(
branch
es
,
sha
)
# This is for ref-less build
s
branches
||=
@project
.
repository
.
branch_names_contains
(
sha
)
def
merge_requests_for
(
branch
)
origin_merge_requests
=
@project
.
origin_merge_request
s
.
opened
.
where
(
source_branch:
branch
).
to_a
return
[]
if
branches
.
blank?
fork_merge_requests
=
@project
.
fork_merge_requests
.
opened
.
where
(
source_branch:
branch
).
to_a
merge_requests
=
@project
.
origin_merge_requests
.
opened
.
where
(
source_branch:
branches
).
to_a
merge_requests
+=
@project
.
fork_merge_requests
.
opened
.
where
(
source_branch:
branches
).
to_a
merge_requests
.
uniq
.
select
(
&
:source_project
)
(
origin_merge_requests
+
fork_merge_requests
)
.
uniq
.
select
(
&
:source_project
)
end
def
pipeline_merge_requests
(
pipeline
)
merge_requests_for
(
pipeline
.
ref
,
pipeline
.
sha
).
each
do
|
merge_request
|
merge_requests_for
(
pipeline
.
ref
).
each
do
|
merge_request
|
next
unless
pipeline
==
merge_request
.
pipeline
yield
merge_request
...
...
@@ -63,8 +62,9 @@ module MergeRequests
end
def
commit_status_merge_requests
(
commit_status
)
merge_requests_for
(
commit_status
.
ref
,
commit_status
.
sha
).
each
do
|
merge_request
|
merge_requests_for
(
commit_status
.
ref
).
each
do
|
merge_request
|
pipeline
=
merge_request
.
pipeline
next
unless
pipeline
next
unless
pipeline
.
sha
==
commit_status
.
sha
...
...
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
View file @
cd584108
...
...
@@ -97,20 +97,9 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
expect
(
MergeWorker
).
not_to
receive
(
:perform_async
)
service
.
trigger
(
unrelated_pipeline
)
end
it
'discovers branches and merges all merge requests when status is success'
do
allow
(
project
.
repository
).
to
receive
(
:branch_names_contains
).
with
(
commit_status
.
sha
).
and_return
([
mr_merge_if_green_enabled
.
source_branch
])
allow
(
pipeline
).
to
receive
(
:success?
).
and_return
(
true
)
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:pipeline
).
and_return
(
pipeline
)
allow
(
pipeline
).
to
receive
(
:success?
).
and_return
(
true
)
expect
(
MergeWorker
).
to
receive
(
:perform_async
)
service
.
trigger
(
commit_status
)
end
end
context
'
properly handles multiple stages
'
do
context
'
when there are multiple stages in the pipeline
'
do
let
(
:ref
)
{
mr_merge_if_green_enabled
.
source_branch
}
let!
(
:build
)
{
create
(
:ci_build
,
:created
,
pipeline:
pipeline
,
ref:
ref
,
name:
'build'
,
stage:
'build'
)
}
let!
(
:test
)
{
create
(
:ci_build
,
:created
,
pipeline:
pipeline
,
ref:
ref
,
name:
'test'
,
stage:
'test'
)
}
...
...
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