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
af7ce322
Commit
af7ce322
authored
Jul 27, 2016
by
Ben Boeckel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webhooks: include old revision in MR update events
parent
ab3dd9a1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
7 deletions
+11
-7
CHANGELOG
CHANGELOG
+1
-0
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+6
-3
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+1
-1
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+3
-3
No files found.
CHANGELOG
View file @
af7ce322
...
...
@@ -20,6 +20,7 @@ v 8.11.0 (unreleased)
- Optimize checking if a user has read access to a list of issues !5370
- Nokogiri's various parsing methods are now instrumented
- Add a way to send an email and create an issue based on private personal token. Find the email address from issues page. !3363
- Include old revision in merge request update hooks (Ben Boeckel)
- Add build event color in HipChat messages (David Eisner)
- Make fork counter always clickable. !5463 (winniehell)
- All created issues, API or WebUI, can be submitted to Akismet for spam check !5333
...
...
app/services/merge_requests/base_service.rb
View file @
af7ce322
...
...
@@ -17,16 +17,19 @@ module MergeRequests
end
end
def
hook_data
(
merge_request
,
action
)
def
hook_data
(
merge_request
,
action
,
oldrev
=
nil
)
hook_data
=
merge_request
.
to_hook_data
(
current_user
)
hook_data
[
:object_attributes
][
:url
]
=
Gitlab
::
UrlBuilder
.
build
(
merge_request
)
hook_data
[
:object_attributes
][
:action
]
=
action
if
oldrev
&&
!
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
hook_data
[
:object_attributes
][
:oldrev
]
=
oldrev
end
hook_data
end
def
execute_hooks
(
merge_request
,
action
=
'open'
)
def
execute_hooks
(
merge_request
,
action
=
'open'
,
oldrev
=
nil
)
if
merge_request
.
project
merge_data
=
hook_data
(
merge_request
,
action
)
merge_data
=
hook_data
(
merge_request
,
action
,
oldrev
)
merge_request
.
project
.
execute_hooks
(
merge_data
,
:merge_request_hooks
)
merge_request
.
project
.
execute_services
(
merge_data
,
:merge_request_hooks
)
end
...
...
app/services/merge_requests/refresh_service.rb
View file @
af7ce322
...
...
@@ -137,7 +137,7 @@ module MergeRequests
# Call merge request webhook with update branches
def
execute_mr_web_hooks
merge_requests_for_source_branch
.
each
do
|
merge_request
|
execute_hooks
(
merge_request
,
'update'
)
execute_hooks
(
merge_request
,
'update'
,
@oldrev
)
end
end
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
af7ce322
...
...
@@ -57,7 +57,7 @@ describe MergeRequests::RefreshService, services: true do
it
'should execute hooks with update action'
do
expect
(
refresh_service
).
to
have_received
(
:execute_hooks
).
with
(
@merge_request
,
'update'
)
with
(
@merge_request
,
'update'
,
@oldrev
)
end
it
{
expect
(
@merge_request
.
notes
).
not_to
be_empty
}
...
...
@@ -113,7 +113,7 @@ describe MergeRequests::RefreshService, services: true do
it
'should execute hooks with update action'
do
expect
(
refresh_service
).
to
have_received
(
:execute_hooks
).
with
(
@fork_merge_request
,
'update'
)
with
(
@fork_merge_request
,
'update'
,
@oldrev
)
end
it
{
expect
(
@merge_request
.
notes
).
to
be_empty
}
...
...
@@ -158,7 +158,7 @@ describe MergeRequests::RefreshService, services: true do
it
'refreshes the merge request'
do
expect
(
refresh_service
).
to
receive
(
:execute_hooks
).
with
(
@fork_merge_request
,
'update'
)
with
(
@fork_merge_request
,
'update'
,
Gitlab
::
Git
::
BLANK_SHA
)
allow_any_instance_of
(
Repository
).
to
receive
(
:merge_base
).
and_return
(
@oldrev
)
refresh_service
.
execute
(
Gitlab
::
Git
::
BLANK_SHA
,
@newrev
,
'refs/heads/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