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
iv
gitlab-ce
Commits
f50b7b5c
Commit
f50b7b5c
authored
Jan 07, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'merge-system-note' into 'master'
Refactor merge request merge service See merge request !1374
parents
6e5c72f8
ee9849b7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
24 deletions
+19
-24
app/models/merge_request.rb
app/models/merge_request.rb
+3
-1
app/services/merge_requests/auto_merge_service.rb
app/services/merge_requests/auto_merge_service.rb
+4
-3
app/services/merge_requests/base_merge_service.rb
app/services/merge_requests/base_merge_service.rb
+1
-12
app/services/merge_requests/merge_service.rb
app/services/merge_requests/merge_service.rb
+4
-3
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+3
-1
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+4
-4
No files found.
app/models/merge_request.rb
View file @
f50b7b5c
...
...
@@ -189,7 +189,9 @@ class MergeRequest < ActiveRecord::Base
end
def
automerge!
(
current_user
,
commit_message
=
nil
)
MergeRequests
::
AutoMergeService
.
new
.
execute
(
self
,
current_user
,
commit_message
)
MergeRequests
::
AutoMergeService
.
new
(
target_project
,
current_user
).
execute
(
self
,
commit_message
)
end
def
open?
...
...
app/services/merge_requests/auto_merge_service.rb
View file @
f50b7b5c
...
...
@@ -5,15 +5,16 @@ module MergeRequests
# mark merge request as merged and execute all hooks and notifications
# Called when you do merge via GitLab UI
class
AutoMergeService
<
BaseMergeService
def
execute
(
merge_request
,
c
urrent_user
,
c
ommit_message
)
def
execute
(
merge_request
,
commit_message
)
merge_request
.
lock_mr
if
Gitlab
::
Satellite
::
MergeAction
.
new
(
current_user
,
merge_request
).
merge!
(
commit_message
)
merge_request
.
merge
notification
.
merge_mr
(
merge_request
,
current_user
)
notification
_service
.
merge_mr
(
merge_request
,
current_user
)
create_merge_event
(
merge_request
,
current_user
)
execute_project_hooks
(
merge_request
)
create_note
(
merge_request
)
execute_hooks
(
merge_request
)
true
else
...
...
app/services/merge_requests/base_merge_service.rb
View file @
f50b7b5c
module
MergeRequests
class
BaseMergeService
class
BaseMergeService
<
MergeRequests
::
BaseService
private
def
notification
NotificationService
.
new
end
def
create_merge_event
(
merge_request
,
current_user
)
EventCreateService
.
new
.
merge_mr
(
merge_request
,
current_user
)
end
def
execute_project_hooks
(
merge_request
)
if
merge_request
.
project
hook_data
=
merge_request
.
to_hook_data
(
current_user
)
merge_request
.
project
.
execute_hooks
(
hook_data
,
:merge_request_hooks
)
end
end
end
end
app/services/merge_requests/merge_service.rb
View file @
f50b7b5c
...
...
@@ -6,12 +6,13 @@ module MergeRequests
# Called when you do merge via command line and push code
# to target branch
class
MergeService
<
BaseMergeService
def
execute
(
merge_request
,
c
urrent_user
,
c
ommit_message
)
def
execute
(
merge_request
,
commit_message
)
merge_request
.
merge
notification
.
merge_mr
(
merge_request
,
current_user
)
notification
_service
.
merge_mr
(
merge_request
,
current_user
)
create_merge_event
(
merge_request
,
current_user
)
execute_project_hooks
(
merge_request
)
create_note
(
merge_request
)
execute_hooks
(
merge_request
)
true
rescue
...
...
app/services/merge_requests/refresh_service.rb
View file @
f50b7b5c
...
...
@@ -32,7 +32,9 @@ module MergeRequests
merge_requests
.
uniq
.
select
(
&
:source_project
).
each
do
|
merge_request
|
MergeRequests
::
MergeService
.
new
.
execute
(
merge_request
,
@current_user
,
nil
)
MergeRequests
::
MergeService
.
new
(
merge_request
.
target_project
,
@current_user
).
execute
(
merge_request
,
nil
)
end
end
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
f50b7b5c
...
...
@@ -47,10 +47,10 @@ describe MergeRequests::RefreshService do
reload_mrs
end
it
{
@merge_request
.
notes
.
should
be_empty
}
it
{
@merge_request
.
notes
.
last
.
note
.
should
include
(
'changed to merged'
)
}
it
{
@merge_request
.
should
be_merged
}
it
{
@fork_merge_request
.
should
be_merged
}
it
{
@fork_merge_request
.
notes
.
should
be_empty
}
it
{
@fork_merge_request
.
notes
.
last
.
note
.
should
include
(
'changed to merged'
)
}
end
context
'push to fork repo source branch'
do
...
...
@@ -61,7 +61,7 @@ describe MergeRequests::RefreshService do
it
{
@merge_request
.
notes
.
should
be_empty
}
it
{
@merge_request
.
should
be_open
}
it
{
@fork_merge_request
.
notes
.
should_not
be_empty
}
it
{
@fork_merge_request
.
notes
.
last
.
note
.
should
include
(
'new commit'
)
}
it
{
@fork_merge_request
.
should
be_open
}
end
...
...
@@ -84,7 +84,7 @@ describe MergeRequests::RefreshService do
reload_mrs
end
it
{
@merge_request
.
notes
.
should
be_empty
}
it
{
@merge_request
.
notes
.
last
.
note
.
should
include
(
'changed to merged'
)
}
it
{
@merge_request
.
should
be_merged
}
it
{
@fork_merge_request
.
should
be_open
}
it
{
@fork_merge_request
.
notes
.
should
be_empty
}
...
...
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