Commit 4603e571 authored by Stan Hu's avatar Stan Hu

Fix duplicated branch creation/deletion Web hooks/service notifications when using Web UI

Similar to 423d2d62, except duplicates occurred only if a Web service (e.g. Slack) were
configured.

When deleting a branch, this is what was happening:

    1. DeleteBranchService calls execute_hooks and execute_services
    2. The call to repository.rm_branch triggers the GitHooksService.
    3. This, in turn, calls GitPushService and then calls the same hooks/services again.

5145706c now makes it no longer necessary for DeleteBranchService and CreateBranchService to execute
the branch hooks/services. Note that tags behave differently in GitTagPushService and GitPushService
is not called.

Closes #10330
parent 706b101f
...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.5.0 (unreleased) v 8.5.0 (unreleased)
- Cache various Repository methods to improve performance (Yorick Peterse) - Cache various Repository methods to improve performance (Yorick Peterse)
- Fix duplicated branch creation/deletion Web hooks/service notifications when using Web UI (Stan Hu)
- Ensure rake tasks that don't need a DB connection can be run without one - Ensure rake tasks that don't need a DB connection can be run without one
- Update New Relic gem to 3.14.1.311 (Stan Hu) - Update New Relic gem to 3.14.1.311 (Stan Hu)
- Add "visibility" flag to GET /projects api endpoint - Add "visibility" flag to GET /projects api endpoint
......
...@@ -29,11 +29,7 @@ class CreateBranchService < BaseService ...@@ -29,11 +29,7 @@ class CreateBranchService < BaseService
end end
if new_branch if new_branch
push_data = build_push_data(project, current_user, new_branch) # GitPushService handles execution of services and hooks for branch pushes
project.execute_hooks(push_data.dup, :push_hooks)
project.execute_services(push_data.dup, :push_hooks)
success(new_branch) success(new_branch)
else else
error('Invalid reference name') error('Invalid reference name')
......
...@@ -25,11 +25,7 @@ class DeleteBranchService < BaseService ...@@ -25,11 +25,7 @@ class DeleteBranchService < BaseService
end end
if repository.rm_branch(current_user, branch_name) if repository.rm_branch(current_user, branch_name)
push_data = build_push_data(branch) # GitPushService handles execution of services and hooks for branch pushes
project.execute_hooks(push_data.dup, :push_hooks)
project.execute_services(push_data.dup, :push_hooks)
success('Branch was removed') success('Branch was removed')
else else
error('Failed to remove branch') error('Failed to remove branch')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment