Skip to content

Commit 3128641

Browse files
committed
Revert "Don't execute git hooks if you create branch as part of other change"
This reverts commit a431ca0.
1 parent f5bc41b commit 3128641

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

app/models/repository.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,14 @@ def find_tag(name)
162162
tags.find { |tag| tag.name == name }
163163
end
164164

165-
def add_branch(user, branch_name, target, with_hooks: true)
165+
def add_branch(user, branch_name, target)
166166
oldrev = Gitlab::Git::BLANK_SHA
167167
ref = Gitlab::Git::BRANCH_REF_PREFIX + branch_name
168168
target = commit(target).try(:id)
169169

170170
return false unless target
171171

172-
if with_hooks
173-
GitHooksService.new.execute(user, path_to_repo, oldrev, target, ref) do
174-
update_ref!(ref, target, oldrev)
175-
end
176-
else
172+
GitHooksService.new.execute(user, path_to_repo, oldrev, target, ref) do
177173
update_ref!(ref, target, oldrev)
178174
end
179175

app/services/commits/change_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def create_target_branch(new_branch)
5555
return success if repository.find_branch(new_branch)
5656

5757
result = CreateBranchService.new(@project, current_user)
58-
.execute(new_branch, @target_branch, source_project: @source_project, with_hooks: false)
58+
.execute(new_branch, @target_branch, source_project: @source_project)
5959

6060
if result[:status] == :error
6161
raise ChangeError, "There was an error creating the source branch: #{result[:message]}"

app/services/create_branch_service.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative 'base_service'
22

33
class CreateBranchService < BaseService
4-
def execute(branch_name, ref, source_project: @project, with_hooks: true)
4+
def execute(branch_name, ref, source_project: @project)
55
valid_branch = Gitlab::GitRefValidator.validate(branch_name)
66

77
unless valid_branch
@@ -26,7 +26,7 @@ def execute(branch_name, ref, source_project: @project, with_hooks: true)
2626

2727
repository.find_branch(branch_name)
2828
else
29-
repository.add_branch(current_user, branch_name, ref, with_hooks: with_hooks)
29+
repository.add_branch(current_user, branch_name, ref)
3030
end
3131

3232
if new_branch

app/services/files/base_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def validate
7474
end
7575

7676
def create_target_branch
77-
result = CreateBranchService.new(project, current_user).execute(@target_branch, @source_branch, source_project: @source_project, with_hooks: false)
77+
result = CreateBranchService.new(project, current_user).execute(@target_branch, @source_branch, source_project: @source_project)
7878

7979
unless result[:status] == :success
8080
raise_error("Something went wrong when we tried to create #{@target_branch} for you: #{result[:message]}")

0 commit comments

Comments
 (0)