BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
cd92c84b
Commit
cd92c84b
authored
Feb 28, 2017
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'only-create-unmergeable-todo-once' into 'master'
Only create unmergeable todos once Closes #28555 See merge request !9513
parents
7733f285
2da8bc3d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
11 deletions
+34
-11
merge_request.rb
app/models/merge_request.rb
+0
-4
merge_when_pipeline_succeeds_service.rb
...es/merge_requests/merge_when_pipeline_succeeds_service.rb
+5
-1
only-create-unmergeable-todo-once.yml
changelogs/unreleased/only-create-unmergeable-todo-once.yml
+4
-0
merge_request_spec.rb
spec/models/merge_request_spec.rb
+0
-6
merge_when_pipeline_succeeds_service_spec.rb
...rge_requests/merge_when_pipeline_succeeds_service_spec.rb
+25
-0
No files found.
app/models/merge_request.rb
View file @
cd92c84b
...
...
@@ -91,10 +91,6 @@ class MergeRequest < ActiveRecord::Base
around_transition
do
|
merge_request
,
transition
,
block
|
Gitlab
::
Timeless
.
timeless
(
merge_request
,
&
block
)
end
after_transition
unchecked: :cannot_be_merged
do
|
merge_request
,
transition
|
TodoService
.
new
.
merge_request_became_unmergeable
(
merge_request
)
end
end
validates
:source_project
,
presence:
true
,
unless:
[
:allow_broken
,
:importing?
,
:closed_without_fork?
]
...
...
app/services/merge_requests/merge_when_pipeline_succeeds_service.rb
View file @
cd92c84b
...
...
@@ -24,7 +24,11 @@ module MergeRequests
pipeline_merge_requests
(
pipeline
)
do
|
merge_request
|
next
unless
merge_request
.
merge_when_build_succeeds?
next
unless
merge_request
.
mergeable?
unless
merge_request
.
mergeable?
todo_service
.
merge_request_became_unmergeable
(
merge_request
)
next
end
MergeWorker
.
perform_async
(
merge_request
.
id
,
merge_request
.
merge_user_id
,
merge_request
.
merge_params
)
end
...
...
changelogs/unreleased/only-create-unmergeable-todo-once.yml
0 → 100644
View file @
cd92c84b
---
title
:
Only create unmergeable todos once when MR fails to merge
merge_request
:
author
:
spec/models/merge_request_spec.rb
View file @
cd92c84b
...
...
@@ -833,12 +833,6 @@ describe MergeRequest, models: true do
it
'becomes unmergeable'
do
expect
{
subject
.
check_if_can_be_merged
}.
to
change
{
subject
.
merge_status
}.
to
(
'cannot_be_merged'
)
end
it
'creates Todo on unmergeability'
do
expect_any_instance_of
(
TodoService
).
to
receive
(
:merge_request_became_unmergeable
).
with
(
subject
)
subject
.
check_if_can_be_merged
end
end
context
'when it has conflicts'
do
...
...
spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb
View file @
cd92c84b
...
...
@@ -111,6 +111,31 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
service
.
trigger
(
unrelated_pipeline
)
end
end
context
'when the merge request is not mergeable'
do
let
(
:mr_conflict
)
do
create
(
:merge_request
,
merge_when_build_succeeds:
true
,
merge_user:
user
,
source_branch:
'master'
,
target_branch:
'feature-conflict'
,
source_project:
project
,
target_project:
project
)
end
let
(
:conflict_pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
ref:
mr_conflict
.
source_branch
,
sha:
mr_conflict
.
diff_head_sha
,
status:
'success'
)
end
it
'does not merge the merge request'
do
expect
(
MergeWorker
).
not_to
receive
(
:perform_async
)
service
.
trigger
(
conflict_pipeline
)
end
it
'creates todos for unmergeability'
do
expect_any_instance_of
(
TodoService
).
to
receive
(
:merge_request_became_unmergeable
).
with
(
mr_conflict
)
service
.
trigger
(
conflict_pipeline
)
end
end
end
describe
"#cancel"
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