Commit 3128641f authored by Lin Jen-Shin's avatar Lin Jen-Shin

Revert "Don't execute git hooks if you create branch as part of other change"

This reverts commit a431ca0f.
parent f5bc41b3
...@@ -162,20 +162,16 @@ class Repository ...@@ -162,20 +162,16 @@ class Repository
tags.find { |tag| tag.name == name } tags.find { |tag| tag.name == name }
end end
def add_branch(user, branch_name, target, with_hooks: true) def add_branch(user, branch_name, target)
oldrev = Gitlab::Git::BLANK_SHA oldrev = Gitlab::Git::BLANK_SHA
ref = Gitlab::Git::BRANCH_REF_PREFIX + branch_name ref = Gitlab::Git::BRANCH_REF_PREFIX + branch_name
target = commit(target).try(:id) target = commit(target).try(:id)
return false unless target return false unless target
if with_hooks
GitHooksService.new.execute(user, path_to_repo, oldrev, target, ref) do GitHooksService.new.execute(user, path_to_repo, oldrev, target, ref) do
update_ref!(ref, target, oldrev) update_ref!(ref, target, oldrev)
end end
else
update_ref!(ref, target, oldrev)
end
after_create_branch after_create_branch
find_branch(branch_name) find_branch(branch_name)
......
...@@ -55,7 +55,7 @@ module Commits ...@@ -55,7 +55,7 @@ module Commits
return success if repository.find_branch(new_branch) return success if repository.find_branch(new_branch)
result = CreateBranchService.new(@project, current_user) result = CreateBranchService.new(@project, current_user)
.execute(new_branch, @target_branch, source_project: @source_project, with_hooks: false) .execute(new_branch, @target_branch, source_project: @source_project)
if result[:status] == :error if result[:status] == :error
raise ChangeError, "There was an error creating the source branch: #{result[:message]}" raise ChangeError, "There was an error creating the source branch: #{result[:message]}"
......
require_relative 'base_service' require_relative 'base_service'
class CreateBranchService < BaseService class CreateBranchService < BaseService
def execute(branch_name, ref, source_project: @project, with_hooks: true) def execute(branch_name, ref, source_project: @project)
valid_branch = Gitlab::GitRefValidator.validate(branch_name) valid_branch = Gitlab::GitRefValidator.validate(branch_name)
unless valid_branch unless valid_branch
...@@ -26,7 +26,7 @@ class CreateBranchService < BaseService ...@@ -26,7 +26,7 @@ class CreateBranchService < BaseService
repository.find_branch(branch_name) repository.find_branch(branch_name)
else else
repository.add_branch(current_user, branch_name, ref, with_hooks: with_hooks) repository.add_branch(current_user, branch_name, ref)
end end
if new_branch if new_branch
......
...@@ -74,7 +74,7 @@ module Files ...@@ -74,7 +74,7 @@ module Files
end end
def create_target_branch def create_target_branch
result = CreateBranchService.new(project, current_user).execute(@target_branch, @source_branch, source_project: @source_project, with_hooks: false) result = CreateBranchService.new(project, current_user).execute(@target_branch, @source_branch, source_project: @source_project)
unless result[:status] == :success unless result[:status] == :success
raise_error("Something went wrong when we tried to create #{@target_branch} for you: #{result[:message]}") raise_error("Something went wrong when we tried to create #{@target_branch} for you: #{result[:message]}")
......
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