diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2016-07-27 22:39:45 +0300 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2016-08-01 18:20:07 +0300 |
commit | af7ce322bdbaf74eaf54eac92c2ed5183e0d8e9c (patch) | |
tree | c776998d6913cef0fd6bd1109585cd70eb6ff9c8 /app/services | |
parent | ab3dd9a106787b70c26e55e9f0dc7fe6c34b0769 (diff) |
webhooks: include old revision in MR update events
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/base_service.rb | 9 | ||||
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index bc3606a14c2..ba424b09463 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -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 diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index 1daf6bbf553..5cedd6f11d9 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -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 |