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
ba87b76d
Commit
ba87b76d
authored
Mar 25, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use EventCreateService for notes, merge requests
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
6cc4ac7b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
24 deletions
+19
-24
app/observers/merge_request_observer.rb
app/observers/merge_request_observer.rb
+3
-16
app/observers/note_observer.rb
app/observers/note_observer.rb
+6
-0
app/services/event_create_service.rb
app/services/event_create_service.rb
+8
-0
app/services/merge_requests/base_merge_service.rb
app/services/merge_requests/base_merge_service.rb
+1
-7
config/application.rb
config/application.rb
+1
-1
No files found.
app/observers/merge_request_observer.rb
View file @
ba87b76d
...
...
@@ -2,24 +2,21 @@ class MergeRequestObserver < ActivityObserver
observe
:merge_request
def
after_create
(
merge_request
)
if
merge_request
.
author_id
create_event
(
merge_request
,
Event
.
determine_action
(
merge_request
))
end
event_service
.
open_mr
(
merge_request
,
current_user
)
notification
.
new_merge_request
(
merge_request
,
current_user
)
merge_request
.
create_cross_references!
(
merge_request
.
project
,
current_user
)
execute_hooks
(
merge_request
)
end
def
after_close
(
merge_request
,
transition
)
create_event
(
merge_request
,
Event
::
CLOSED
)
event_service
.
close_mr
(
merge_request
,
current_user
)
notification
.
close_mr
(
merge_request
,
current_user
)
create_note
(
merge_request
)
execute_hooks
(
merge_request
)
end
def
after_reopen
(
merge_request
,
transition
)
create_event
(
merge_request
,
Event
::
REOPENED
)
event_service
.
reopen_mr
(
merge_request
,
current_user
)
create_note
(
merge_request
)
execute_hooks
(
merge_request
)
merge_request
.
reload_code
...
...
@@ -33,16 +30,6 @@ class MergeRequestObserver < ActivityObserver
execute_hooks
(
merge_request
)
end
def
create_event
(
record
,
status
)
Event
.
create
(
project:
record
.
target_project
,
target_id:
record
.
id
,
target_type:
record
.
class
.
name
,
action:
status
,
author_id:
current_user
.
id
)
end
private
# Create merge request note with service comment like 'Status changed to closed'
...
...
app/observers/note_observer.rb
View file @
ba87b76d
...
...
@@ -2,6 +2,12 @@ class NoteObserver < BaseObserver
def
after_create
(
note
)
notification
.
new_note
(
note
)
# Skip system notes, like status changes and cross-references.
# Skip wall notes to prevent spamming of dashboard
if
note
.
noteable_type
.
present?
&&
!
note
.
system
event_service
.
leave_note
(
note
,
current_user
)
end
unless
note
.
system?
# Create a cross-reference note if this Note contains GFM that names an
# issue, merge request, or commit.
...
...
app/services/event_create_service.rb
View file @
ba87b76d
...
...
@@ -42,6 +42,14 @@ class EventCreateService
create_event
(
milestone
,
current_user
,
Event
::
CLOSED
)
end
def
reopen_milestone
(
milestone
,
current_user
)
create_event
(
milestone
,
current_user
,
Event
::
REOPENED
)
end
def
leave_note
(
note
,
current_user
)
create_event
(
note
,
current_user
,
Event
::
COMMENTED
)
end
private
def
create_event
(
record
,
current_user
,
status
)
...
...
app/services/merge_requests/base_merge_service.rb
View file @
ba87b76d
...
...
@@ -8,13 +8,7 @@ module MergeRequests
end
def
create_merge_event
(
merge_request
,
current_user
)
Event
.
create
(
project:
merge_request
.
target_project
,
target_id:
merge_request
.
id
,
target_type:
merge_request
.
class
.
name
,
action:
Event
::
MERGED
,
author_id:
current_user
.
id
)
EventCreateService
.
new
.
merge_mr
(
merge_request
,
current_user
)
end
def
execute_project_hooks
(
merge_request
)
...
...
config/application.rb
View file @
ba87b76d
...
...
@@ -19,7 +19,7 @@ module Gitlab
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
config
.
active_record
.
observers
=
:
activity
_observer
,
config
.
active_record
.
observers
=
:
milestone
_observer
,
:project_activity_cache_observer
,
:issue_observer
,
:key_observer
,
...
...
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