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
892158f1
Commit
892158f1
authored
May 13, 2015
by
Jeroen van Baarsen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8872 from baloo/feature/execute_mr_webhooks_upon_commit
Call merge request web hook for each commits
parents
cb8f974b
a927bf56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
3 deletions
+33
-3
CHANGELOG
CHANGELOG
+1
-0
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+15
-0
doc/web_hooks/web_hooks.md
doc/web_hooks/web_hooks.md
+1
-1
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+16
-2
No files found.
CHANGELOG
View file @
892158f1
...
@@ -56,6 +56,7 @@ v 7.11.0 (unreleased)
...
@@ -56,6 +56,7 @@ v 7.11.0 (unreleased)
- Add "Create Merge Request" buttons to commits and branches pages and push event.
- Add "Create Merge Request" buttons to commits and branches pages and push event.
- Show user roles by comments.
- Show user roles by comments.
- Fix automatic blocking of auto-created users from Active Directory.
- Fix automatic blocking of auto-created users from Active Directory.
- Call merge request web hook for each new commits (Arthur Gautier)
v 7.10.2
v 7.10.2
- Fix CI links on MR page
- Fix CI links on MR page
...
...
app/services/merge_requests/refresh_service.rb
View file @
892158f1
...
@@ -10,6 +10,7 @@ module MergeRequests
...
@@ -10,6 +10,7 @@ module MergeRequests
close_merge_requests
close_merge_requests
reload_merge_requests
reload_merge_requests
execute_mr_web_hooks
comment_mr_with_commits
comment_mr_with_commits
true
true
...
@@ -88,6 +89,20 @@ module MergeRequests
...
@@ -88,6 +89,20 @@ module MergeRequests
end
end
end
end
# Call merge request webhook with update branches
def
execute_mr_web_hooks
merge_requests
=
@project
.
origin_merge_requests
.
opened
.
where
(
source_branch:
@branch_name
)
.
to_a
merge_requests
+=
@fork_merge_requests
.
where
(
source_branch:
@branch_name
)
.
to_a
merge_requests
=
filter_merge_requests
(
merge_requests
)
merge_requests
.
each
do
|
merge_request
|
execute_hooks
(
merge_request
,
'update'
)
end
end
def
filter_merge_requests
(
merge_requests
)
def
filter_merge_requests
(
merge_requests
)
merge_requests
.
uniq
.
select
(
&
:source_project
)
merge_requests
.
uniq
.
select
(
&
:source_project
)
end
end
...
...
doc/web_hooks/web_hooks.md
View file @
892158f1
...
@@ -143,7 +143,7 @@ X-Gitlab-Event: Issue Hook
...
@@ -143,7 +143,7 @@ X-Gitlab-Event: Issue Hook
## Merge request events
## Merge request events
Triggered when a new merge request is created
or an existing merge request was updated/merged/closed
.
Triggered when a new merge request is created
, an existing merge request was updated/merged/closed or a commit is added in the source branch
.
**Request header**
:
**Request header**
:
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
892158f1
...
@@ -30,11 +30,18 @@ describe MergeRequests::RefreshService do
...
@@ -30,11 +30,18 @@ describe MergeRequests::RefreshService do
end
end
context
'push to origin repo source branch'
do
context
'push to origin repo source branch'
do
let
(
:refresh_service
)
{
service
.
new
(
@project
,
@user
)
}
before
do
before
do
service
.
new
(
@project
,
@user
).
execute
(
@oldrev
,
@newrev
,
'refs/heads/master'
)
allow
(
refresh_service
).
to
receive
(
:execute_hooks
)
refresh_service
.
execute
(
@oldrev
,
@newrev
,
'refs/heads/master'
)
reload_mrs
reload_mrs
end
end
it
'should execute hooks with update action'
do
expect
(
refresh_service
).
to
have_received
(
:execute_hooks
).
with
(
@merge_request
,
'update'
)
end
it
{
expect
(
@merge_request
.
notes
).
not_to
be_empty
}
it
{
expect
(
@merge_request
.
notes
).
not_to
be_empty
}
it
{
expect
(
@merge_request
).
to
be_open
}
it
{
expect
(
@merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
...
@@ -54,11 +61,18 @@ describe MergeRequests::RefreshService do
...
@@ -54,11 +61,18 @@ describe MergeRequests::RefreshService do
end
end
context
'push to fork repo source branch'
do
context
'push to fork repo source branch'
do
let
(
:refresh_service
)
{
service
.
new
(
@fork_project
,
@user
)
}
before
do
before
do
service
.
new
(
@fork_project
,
@user
).
execute
(
@oldrev
,
@newrev
,
'refs/heads/master'
)
allow
(
refresh_service
).
to
receive
(
:execute_hooks
)
refresh_service
.
execute
(
@oldrev
,
@newrev
,
'refs/heads/master'
)
reload_mrs
reload_mrs
end
end
it
'should execute hooks with update action'
do
expect
(
refresh_service
).
to
have_received
(
:execute_hooks
).
with
(
@fork_merge_request
,
'update'
)
end
it
{
expect
(
@merge_request
.
notes
).
to
be_empty
}
it
{
expect
(
@merge_request
.
notes
).
to
be_empty
}
it
{
expect
(
@merge_request
).
to
be_open
}
it
{
expect
(
@merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'Added 4 commits'
)
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'Added 4 commits'
)
}
...
...
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