From a431ca0f8b7f8967e89a35caddf1e41e53eee290 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 2 Nov 2016 11:39:12 +0100 Subject: Don't execute git hooks if you create branch as part of other change Currently, our procedure for adding a commit requires us to execute `CreateBranchService` before file creation. It's OK, but also we do execute `git hooks` (the `PostReceive` sidekiq job) as part of this process. However, this hook is execute before the file is actually committed, so the ref is updated. Secondly, we do execute a `git hooks` after committing file and updating ref. This results in duplicate `PostReceive` jobs, where the first one is completely invalid. This change makes the branch creation, something that is intermediate step of bigger process (file creation or update, commit cherry pick or revert) to not execute git hooks. --- app/services/create_branch_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/services/create_branch_service.rb') diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb index 757fc35a78f..a6a3461e17b 100644 --- a/app/services/create_branch_service.rb +++ b/app/services/create_branch_service.rb @@ -1,7 +1,7 @@ require_relative 'base_service' class CreateBranchService < BaseService - def execute(branch_name, ref, source_project: @project) + def execute(branch_name, ref, source_project: @project, with_hooks: true) valid_branch = Gitlab::GitRefValidator.validate(branch_name) unless valid_branch @@ -26,7 +26,7 @@ class CreateBranchService < BaseService repository.find_branch(branch_name) else - repository.add_branch(current_user, branch_name, ref) + repository.add_branch(current_user, branch_name, ref, with_hooks: with_hooks) end if new_branch -- cgit v1.2.1