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
Jérome Perrin
gitlab-ce
Commits
86f43912
Commit
86f43912
authored
Aug 28, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleans merge_jid when possible on MergeService
parent
ffc576d7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
app/services/merge_requests/merge_service.rb
app/services/merge_requests/merge_service.rb
+6
-3
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+28
-5
No files found.
app/services/merge_requests/merge_service.rb
View file @
86f43912
...
@@ -26,14 +26,13 @@ module MergeRequests
...
@@ -26,14 +26,13 @@ module MergeRequests
merge_request
.
in_locked_state
do
merge_request
.
in_locked_state
do
if
commit
if
commit
after_merge
after_merge
clean_merge_jid
success
success
end
end
end
end
rescue
MergeError
=>
e
rescue
MergeError
=>
e
clean_merge_jid
log_merge_error
(
e
.
message
,
save_message_on_model:
true
)
log_merge_error
(
e
.
message
,
save_message_on_model:
true
)
ensure
# Make sure to clean up merge_jid in the end of the merge process.
merge_request
.
update_column
(
:merge_jid
,
nil
)
end
end
private
private
...
@@ -73,6 +72,10 @@ module MergeRequests
...
@@ -73,6 +72,10 @@ module MergeRequests
end
end
end
end
def
clean_merge_jid
merge_request
.
update_column
(
:merge_jid
,
nil
)
end
def
branch_deletion_user
def
branch_deletion_user
@merge_request
.
force_remove_source_branch?
?
@merge_request
.
author
:
current_user
@merge_request
.
force_remove_source_branch?
?
@merge_request
.
author
:
current_user
end
end
...
...
spec/services/merge_requests/merge_service_spec.rb
View file @
86f43912
...
@@ -12,15 +12,38 @@ describe MergeRequests::MergeService do
...
@@ -12,15 +12,38 @@ describe MergeRequests::MergeService do
end
end
describe
'#execute'
do
describe
'#execute'
do
it
'cleans up merge_jid from MergeRequest'
do
context
'MergeRequest#merge_jid'
do
before
do
merge_request
.
update_column
(
:merge_jid
,
'hash-123'
)
merge_request
.
update_column
(
:merge_jid
,
'hash-123'
)
end
it
'is cleaned when no error is raised'
do
service
=
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
reload
.
merge_jid
).
to
be_nil
end
it
'is cleaned when expected error is raised'
do
service
=
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
service
=
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
allow
(
service
).
to
receive
(
:commit
).
and_raise
(
described_class
::
MergeError
)
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
reload
.
merge_jid
).
to
be_nil
expect
(
merge_request
.
reload
.
merge_jid
).
to
be_nil
end
end
it
'is not cleaned when unexpected error is raised'
do
service
=
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
allow
(
service
).
to
receive
(
:commit
).
and_raise
(
StandardError
)
expect
{
service
.
execute
(
merge_request
)
}.
to
raise_error
(
StandardError
)
expect
(
merge_request
.
reload
.
merge_jid
).
to
be_present
end
end
context
'valid params'
do
context
'valid params'
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
...
...
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