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
03b44916
Commit
03b44916
authored
Oct 03, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7754 from Bugagazavr/hooks
More information in merge request hook
parents
1c077cac
1c9d2e39
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
12 deletions
+70
-12
app/models/commit.rb
app/models/commit.rb
+15
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-1
app/models/issue.rb
app/models/issue.rb
+4
-0
app/models/merge_request.rb
app/models/merge_request.rb
+14
-0
app/models/project.rb
app/models/project.rb
+10
-0
app/services/git_push_service.rb
app/services/git_push_service.rb
+1
-10
doc/web_hooks/web_hooks.md
doc/web_hooks/web_hooks.md
+25
-1
No files found.
app/models/commit.rb
View file @
03b44916
...
@@ -88,6 +88,21 @@ class Commit
...
@@ -88,6 +88,21 @@ class Commit
description
.
present?
description
.
present?
end
end
def
hook_attrs
(
project
)
path_with_namespace
=
project
.
path_with_namespace
{
id:
id
,
message:
safe_message
,
timestamp:
committed_date
.
xmlschema
,
url:
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
path_with_namespace
}
/commit/
#{
id
}
"
,
author:
{
name:
author_name
,
email:
author_email
}
}
end
# Discover issues should be closed when this commit is pushed to a project's
# Discover issues should be closed when this commit is pushed to a project's
# default branch.
# default branch.
def
closes_issues
(
project
)
def
closes_issues
(
project
)
...
...
app/models/concerns/issuable.rb
View file @
03b44916
...
@@ -134,7 +134,7 @@ module Issuable
...
@@ -134,7 +134,7 @@ module Issuable
def
to_hook_data
def
to_hook_data
{
{
object_kind:
self
.
class
.
name
.
underscore
,
object_kind:
self
.
class
.
name
.
underscore
,
object_attributes:
self
.
attribute
s
object_attributes:
hook_attr
s
}
}
end
end
...
...
app/models/issue.rb
View file @
03b44916
...
@@ -48,6 +48,10 @@ class Issue < ActiveRecord::Base
...
@@ -48,6 +48,10 @@ class Issue < ActiveRecord::Base
state
:closed
state
:closed
end
end
def
hook_attrs
attributes
end
# Mentionable overrides.
# Mentionable overrides.
def
gfm_reference
def
gfm_reference
...
...
app/models/merge_request.rb
View file @
03b44916
...
@@ -211,6 +211,20 @@ class MergeRequest < ActiveRecord::Base
...
@@ -211,6 +211,20 @@ class MergeRequest < ActiveRecord::Base
Gitlab
::
Satellite
::
MergeAction
.
new
(
current_user
,
self
).
format_patch
Gitlab
::
Satellite
::
MergeAction
.
new
(
current_user
,
self
).
format_patch
end
end
def
hook_attrs
attrs
=
{
source:
source_project
.
hook_attrs
,
target:
target_project
.
hook_attrs
,
last_commit:
nil
}
unless
last_commit
.
nil?
attrs
.
merge!
(
last_commit:
last_commit
.
hook_attrs
(
source_project
))
end
attributes
.
merge!
(
attrs
)
end
def
for_fork?
def
for_fork?
target_project
!=
source_project
target_project
!=
source_project
end
end
...
...
app/models/project.rb
View file @
03b44916
...
@@ -544,6 +544,16 @@ class Project < ActiveRecord::Base
...
@@ -544,6 +544,16 @@ class Project < ActiveRecord::Base
end
end
end
end
def
hook_attrs
{
name:
name
,
ssh_url:
ssh_url_to_repo
,
http_url:
http_url_to_repo
,
namespace:
namespace
.
name
,
visibility_level:
visibility_level
}
end
# Reset events cache related to this project
# Reset events cache related to this project
#
#
# Since we do cache @event we need to reset cache in special cases:
# Since we do cache @event we need to reset cache in special cases:
...
...
app/services/git_push_service.rb
View file @
03b44916
...
@@ -150,16 +150,7 @@ class GitPushService
...
@@ -150,16 +150,7 @@ class GitPushService
# will be passed as post receive hook data.
# will be passed as post receive hook data.
#
#
push_commits_limited
.
each
do
|
commit
|
push_commits_limited
.
each
do
|
commit
|
data
[
:commits
]
<<
{
data
[
:commits
]
<<
commit
.
hook_attrs
(
project
)
id:
commit
.
id
,
message:
commit
.
safe_message
,
timestamp:
commit
.
committed_date
.
xmlschema
,
url:
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
path_with_namespace
}
/commit/
#{
commit
.
id
}
"
,
author:
{
name:
commit
.
author_name
,
email:
commit
.
author_email
}
}
end
end
data
data
...
...
doc/web_hooks/web_hooks.md
View file @
03b44916
...
@@ -109,7 +109,31 @@ Triggered when a new merge request is created or an existing merge request was u
...
@@ -109,7 +109,31 @@ Triggered when a new merge request is created or an existing merge request was u
"merge_status"
:
"unchecked"
,
"merge_status"
:
"unchecked"
,
"target_project_id"
:
14
,
"target_project_id"
:
14
,
"iid"
:
1
,
"iid"
:
1
,
"description"
:
""
"description"
:
""
,
"source"
:
{
"name"
:
"awesome_project"
,
"ssh_url"
:
"ssh://git@example.com/awesome_space/awesome_project.git"
,
"http_url"
:
"http://example.com/awesome_space/awesome_project.git"
,
"visibility_level"
:
20
,
"namespace"
:
"awesome_space"
},
"target"
:
{
"name"
:
"awesome_project"
,
"ssh_url"
:
"ssh://git@example.com/awesome_space/awesome_project.git"
,
"http_url"
:
"http://example.com/awesome_space/awesome_project.git"
,
"visibility_level"
:
20
,
"namespace"
:
"awesome_space"
},
"last_commit"
:
{
"id"
:
"da1560886d4f094c3e6c9ef40349f7d38b5d27d7"
,
"message"
:
"fixed readme"
,
"timestamp"
:
"2012-01-03T23:36:29+02:00"
,
"url"
:
"http://example.com/awesome_space/awesome_project/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7"
,
"author"
:
{
"name"
:
"GitLab dev user"
,
"email"
:
"gitlabdev@dv6700.(none)"
}
}
}
}
}
}
```
```
...
...
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