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
959ad992
Commit
959ad992
authored
Feb 28, 2019
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ref merge does not fail upon FF config enabled
parent
81a0cc25
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
43 deletions
+2
-43
app/services/merge_requests/merge_to_ref_service.rb
app/services/merge_requests/merge_to_ref_service.rb
+1
-9
spec/services/merge_requests/merge_to_ref_service_spec.rb
spec/services/merge_requests/merge_to_ref_service_spec.rb
+1
-34
No files found.
app/services/merge_requests/merge_to_ref_service.rb
View file @
959ad992
...
...
@@ -20,7 +20,7 @@ module MergeRequests
raise_error
(
'Conflicts detected during merge'
)
unless
commit_id
success
(
commit_id:
commit_id
)
success
(
commit_id:
commit_id
,
source_id:
source
)
rescue
MergeError
=>
error
error
(
error
.
message
)
end
...
...
@@ -38,12 +38,8 @@ module MergeRequests
error
=
if
Feature
.
disabled?
(
:merge_to_tmp_merge_ref_path
,
project
)
'Feature is not enabled'
elsif
!
merge_method_supported?
"
#{
project
.
human_merge_method
}
to
#{
target_ref
}
is currently not supported."
elsif
!
hooks_validation_pass?
(
merge_request
)
hooks_validation_error
(
merge_request
)
elsif
@merge_request
.
should_be_rebased?
'Fast-forward merge is not possible. Please update your source branch.'
elsif
!
@merge_request
.
mergeable_to_ref?
"Merge request is not mergeable to
#{
target_ref
}
"
elsif
!
source
...
...
@@ -68,9 +64,5 @@ module MergeRequests
rescue
Gitlab
::
Git
::
PreReceiveError
=>
error
raise
MergeError
,
error
.
message
end
def
merge_method_supported?
[
:merge
,
:rebase_merge
].
include?
(
project
.
merge_method
)
end
end
end
spec/services/merge_requests/merge_to_ref_service_spec.rb
View file @
959ad992
...
...
@@ -52,6 +52,7 @@ describe MergeRequests::MergeToRefService do
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
result
[
:commit_id
]).
to
be_present
expect
(
result
[
:source_id
]).
to
eq
(
merge_request
.
source_branch_sha
)
expect
(
repository
.
ref_exists?
(
target_ref
)).
to
be
(
true
)
expect
(
ref_head
.
id
).
to
eq
(
result
[
:commit_id
])
end
...
...
@@ -115,41 +116,7 @@ describe MergeRequests::MergeToRefService do
end
context
'merge pre-condition checks'
do
before
do
merge_request
.
project
.
update!
(
merge_method:
merge_method
)
end
context
'when semi-linear merge method'
do
let
(
:merge_method
)
{
:rebase_merge
}
it
'return error when MR should be able to fast-forward'
do
allow
(
merge_request
).
to
receive
(
:should_be_rebased?
)
{
true
}
error_message
=
'Fast-forward merge is not possible. Please update your source branch.'
result
=
service
.
execute
(
merge_request
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
error_message
)
end
end
context
'when fast-forward merge method'
do
let
(
:merge_method
)
{
:ff
}
it
'returns error'
do
error_message
=
"Fast-forward to
#{
merge_request
.
merge_ref_path
}
is currently not supported."
result
=
service
.
execute
(
merge_request
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
error_message
)
end
end
context
'when MR is not mergeable to ref'
do
let
(
:merge_method
)
{
:merge
}
it
'returns error'
do
allow
(
merge_request
).
to
receive
(
:mergeable_to_ref?
)
{
false
}
...
...
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