BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
5c6b21f1
Commit
5c6b21f1
authored
Nov 05, 2014
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7967 from Bugagazavr/issue-actor
Add issueable actor to hooks
parents
652f4c80
11848feb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
4 deletions
+25
-4
issuable.rb
app/models/concerns/issuable.rb
+2
-1
user.rb
app/models/user.rb
+8
-0
base_service.rb
app/services/issues/base_service.rb
+1
-1
base_merge_service.rb
app/services/merge_requests/base_merge_service.rb
+2
-1
base_service.rb
app/services/merge_requests/base_service.rb
+2
-1
web_hooks.md
doc/web_hooks/web_hooks.md
+10
-0
No files found.
app/models/concerns/issuable.rb
View file @
5c6b21f1
...
...
@@ -131,9 +131,10 @@ module Issuable
users
.
concat
(
mentions
.
reduce
([],
:|
)).
uniq
end
def
to_hook_data
def
to_hook_data
(
user
)
{
object_kind:
self
.
class
.
name
.
underscore
,
user:
user
.
hook_attrs
,
object_attributes:
hook_attrs
}
end
...
...
app/models/user.rb
View file @
5c6b21f1
...
...
@@ -498,6 +498,14 @@ class User < ActiveRecord::Base
end
end
def
hook_attrs
{
name:
name
,
username:
username
,
avatar_url:
avatar_url
}
end
def
ensure_namespace_correct
# Ensure user has namespace
self
.
create_namespace!
(
path:
self
.
username
,
name:
self
.
username
)
unless
self
.
namespace
...
...
app/services/issues/base_service.rb
View file @
5c6b21f1
...
...
@@ -4,7 +4,7 @@ module Issues
private
def
execute_hooks
(
issue
,
action
=
'open'
)
issue_data
=
issue
.
to_hook_data
issue_data
=
issue
.
to_hook_data
(
current_user
)
issue_url
=
Gitlab
::
UrlBuilder
.
new
(
:issue
).
build
(
issue
.
id
)
issue_data
[
:object_attributes
].
merge!
(
url:
issue_url
,
action:
action
)
issue
.
project
.
execute_hooks
(
issue_data
,
:issue_hooks
)
...
...
app/services/merge_requests/base_merge_service.rb
View file @
5c6b21f1
...
...
@@ -13,7 +13,8 @@ module MergeRequests
def
execute_project_hooks
(
merge_request
)
if
merge_request
.
project
merge_request
.
project
.
execute_hooks
(
merge_request
.
to_hook_data
,
:merge_request_hooks
)
hook_data
=
merge_request
.
to_hook_data
(
current_user
)
merge_request
.
project
.
execute_hooks
(
hook_data
,
:merge_request_hooks
)
end
end
end
...
...
app/services/merge_requests/base_service.rb
View file @
5c6b21f1
...
...
@@ -7,7 +7,8 @@ module MergeRequests
def
execute_hooks
(
merge_request
)
if
merge_request
.
project
merge_request
.
project
.
execute_hooks
(
merge_request
.
to_hook_data
,
:merge_request_hooks
)
hook_data
=
merge_request
.
to_hook_data
(
current_user
)
merge_request
.
project
.
execute_hooks
(
hook_data
,
:merge_request_hooks
)
end
end
end
...
...
doc/web_hooks/web_hooks.md
View file @
5c6b21f1
...
...
@@ -63,6 +63,11 @@ Triggered when a new issue is created or an existing issue was updated/closed/re
```
json
{
"object_kind"
:
"issue"
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40
\u
0026d=identicon"
},
"object_attributes"
:
{
"id"
:
301
,
"title"
:
"New API: create/update/delete file"
,
...
...
@@ -92,6 +97,11 @@ Triggered when a new merge request is created or an existing merge request was u
```
json
{
"object_kind"
:
"merge_request"
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40
\u
0026d=identicon"
},
"object_attributes"
:
{
"id"
:
99
,
"target_branch"
:
"master"
,
...
...
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