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
e2bfddf2
Commit
e2bfddf2
authored
Jun 26, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MWPS system notes shows inconsistent sha
Fix the system note service
parent
63a9c26a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
23 additions
and
10 deletions
+23
-10
app/services/auto_merge/merge_when_pipeline_succeeds_service.rb
...rvices/auto_merge/merge_when_pipeline_succeeds_service.rb
+1
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+2
-2
ee/app/services/auto_merge/add_to_merge_train_when_pipeline_succeeds_service.rb
...erge/add_to_merge_train_when_pipeline_succeeds_service.rb
+1
-1
ee/app/services/ee/system_note_service.rb
ee/app/services/ee/system_note_service.rb
+2
-2
ee/changelogs/unreleased/fix-mwps-shows-inconsistent-sha.yml
ee/changelogs/unreleased/fix-mwps-shows-inconsistent-sha.yml
+5
-0
ee/spec/services/auto_merge/add_to_merge_train_when_pipeline_succeeds_service_spec.rb
...add_to_merge_train_when_pipeline_succeeds_service_spec.rb
+1
-1
ee/spec/services/system_note_service_spec.rb
ee/spec/services/system_note_service_spec.rb
+1
-1
spec/services/auto_merge/base_service_spec.rb
spec/services/auto_merge/base_service_spec.rb
+5
-0
spec/services/auto_merge/merge_when_pipeline_succeeds_service_spec.rb
...s/auto_merge/merge_when_pipeline_succeeds_service_spec.rb
+4
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+1
-1
No files found.
app/services/auto_merge/merge_when_pipeline_succeeds_service.rb
View file @
e2bfddf2
...
@@ -5,7 +5,7 @@ module AutoMerge
...
@@ -5,7 +5,7 @@ module AutoMerge
def
execute
(
merge_request
)
def
execute
(
merge_request
)
super
do
super
do
if
merge_request
.
saved_change_to_auto_merge_enabled?
if
merge_request
.
saved_change_to_auto_merge_enabled?
SystemNoteService
.
merge_when_pipeline_succeeds
(
merge_request
,
project
,
current_user
,
merge_request
.
diff_head_commit
)
SystemNoteService
.
merge_when_pipeline_succeeds
(
merge_request
,
project
,
current_user
,
merge_request
.
actual_head_pipeline
.
sha
)
end
end
end
end
end
end
...
...
app/services/system_note_service.rb
View file @
e2bfddf2
...
@@ -221,8 +221,8 @@ module SystemNoteService
...
@@ -221,8 +221,8 @@ module SystemNoteService
end
end
# Called when 'merge when pipeline succeeds' is executed
# Called when 'merge when pipeline succeeds' is executed
def
merge_when_pipeline_succeeds
(
noteable
,
project
,
author
,
last_commit
)
def
merge_when_pipeline_succeeds
(
noteable
,
project
,
author
,
sha
)
body
=
"enabled an automatic merge when the pipeline for
#{
last_commit
.
to_reference
(
project
)
}
succeeds"
body
=
"enabled an automatic merge when the pipeline for
#{
sha
}
succeeds"
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'merge'
))
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'merge'
))
end
end
...
...
ee/app/services/auto_merge/add_to_merge_train_when_pipeline_succeeds_service.rb
View file @
e2bfddf2
...
@@ -4,7 +4,7 @@ module AutoMerge
...
@@ -4,7 +4,7 @@ module AutoMerge
class
AddToMergeTrainWhenPipelineSucceedsService
<
AutoMerge
::
BaseService
class
AddToMergeTrainWhenPipelineSucceedsService
<
AutoMerge
::
BaseService
def
execute
(
merge_request
)
def
execute
(
merge_request
)
super
do
super
do
SystemNoteService
.
add_to_merge_train_when_pipeline_succeeds
(
merge_request
,
project
,
current_user
,
merge_request
.
diff_head_commit
)
SystemNoteService
.
add_to_merge_train_when_pipeline_succeeds
(
merge_request
,
project
,
current_user
,
merge_request
.
actual_head_pipeline
.
sha
)
end
end
end
end
...
...
ee/app/services/ee/system_note_service.rb
View file @
e2bfddf2
...
@@ -212,8 +212,8 @@ module EE
...
@@ -212,8 +212,8 @@ module EE
end
end
# Called when 'add to merge train when pipeline succeeds' is executed
# Called when 'add to merge train when pipeline succeeds' is executed
def
add_to_merge_train_when_pipeline_succeeds
(
noteable
,
project
,
author
,
last_commit
)
def
add_to_merge_train_when_pipeline_succeeds
(
noteable
,
project
,
author
,
sha
)
body
=
"enabled automatic add to merge train when the pipeline for
#{
last_commit
.
to_reference
(
project
)
}
succeeds"
body
=
"enabled automatic add to merge train when the pipeline for
#{
sha
}
succeeds"
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'merge'
))
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'merge'
))
end
end
...
...
ee/changelogs/unreleased/fix-mwps-shows-inconsistent-sha.yml
0 → 100644
View file @
e2bfddf2
---
title
:
Fix MWPS/ADMTWPS system notes shows wrong sha
merge_request
:
14397
author
:
type
:
fixed
ee/spec/services/auto_merge/add_to_merge_train_when_pipeline_succeeds_service_spec.rb
View file @
e2bfddf2
...
@@ -29,7 +29,7 @@ describe AutoMerge::AddToMergeTrainWhenPipelineSucceedsService do
...
@@ -29,7 +29,7 @@ describe AutoMerge::AddToMergeTrainWhenPipelineSucceedsService do
it
'enables auto merge'
do
it
'enables auto merge'
do
expect
(
SystemNoteService
)
expect
(
SystemNoteService
)
.
to
receive
(
:add_to_merge_train_when_pipeline_succeeds
)
.
to
receive
(
:add_to_merge_train_when_pipeline_succeeds
)
.
with
(
merge_request
,
project
,
user
,
merge_request
.
diff_head_commit
)
.
with
(
merge_request
,
project
,
user
,
merge_request
.
actual_head_pipeline
.
sha
)
subject
subject
...
...
ee/spec/services/system_note_service_spec.rb
View file @
e2bfddf2
...
@@ -372,7 +372,7 @@ describe SystemNoteService do
...
@@ -372,7 +372,7 @@ describe SystemNoteService do
end
end
describe
'.add_to_merge_train_when_pipeline_succeeds'
do
describe
'.add_to_merge_train_when_pipeline_succeeds'
do
subject
{
described_class
.
add_to_merge_train_when_pipeline_succeeds
(
noteable
,
project
,
author
,
noteable
.
diff_head_commit
)
}
subject
{
described_class
.
add_to_merge_train_when_pipeline_succeeds
(
noteable
,
project
,
author
,
pipeline
.
sha
)
}
let
(
:pipeline
)
{
build
(
:ci_pipeline_without_jobs
)
}
let
(
:pipeline
)
{
build
(
:ci_pipeline_without_jobs
)
}
...
...
spec/services/auto_merge/base_service_spec.rb
View file @
e2bfddf2
...
@@ -59,6 +59,11 @@ describe AutoMerge::BaseService do
...
@@ -59,6 +59,11 @@ describe AutoMerge::BaseService do
context
'when strategy is merge when pipeline succeeds'
do
context
'when strategy is merge when pipeline succeeds'
do
let
(
:service
)
{
AutoMerge
::
MergeWhenPipelineSucceedsService
.
new
(
project
,
user
)
}
let
(
:service
)
{
AutoMerge
::
MergeWhenPipelineSucceedsService
.
new
(
project
,
user
)
}
before
do
pipeline
=
build
(
:ci_pipeline
)
allow
(
merge_request
).
to
receive
(
:actual_head_pipeline
)
{
pipeline
}
end
it
'sets the auto merge strategy'
do
it
'sets the auto merge strategy'
do
subject
subject
...
...
spec/services/auto_merge/merge_when_pipeline_succeeds_service_spec.rb
View file @
e2bfddf2
...
@@ -64,8 +64,11 @@ describe AutoMerge::MergeWhenPipelineSucceedsService do
...
@@ -64,8 +64,11 @@ describe AutoMerge::MergeWhenPipelineSucceedsService do
end
end
it
'creates a system note'
do
it
'creates a system note'
do
pipeline
=
build
(
:ci_pipeline
)
allow
(
merge_request
).
to
receive
(
:actual_head_pipeline
)
{
pipeline
}
note
=
merge_request
.
notes
.
last
note
=
merge_request
.
notes
.
last
expect
(
note
.
note
).
to
match
%r{enabled an automatic merge when the pipeline for (
\w
+/
\w
+@)?
\h
{8}}
expect
(
note
.
note
).
to
match
"enabled an automatic merge when the pipeline for
#{
pipeline
.
sha
}
"
end
end
end
end
...
...
spec/services/system_note_service_spec.rb
View file @
e2bfddf2
...
@@ -332,7 +332,7 @@ describe SystemNoteService do
...
@@ -332,7 +332,7 @@ describe SystemNoteService do
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
end
end
subject
{
described_class
.
merge_when_pipeline_succeeds
(
noteable
,
project
,
author
,
noteable
.
diff_head_commit
)
}
subject
{
described_class
.
merge_when_pipeline_succeeds
(
noteable
,
project
,
author
,
pipeline
.
sha
)
}
it_behaves_like
'a system note'
do
it_behaves_like
'a system note'
do
let
(
:action
)
{
'merge'
}
let
(
:action
)
{
'merge'
}
...
...
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