diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-02 11:39:12 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-03 10:14:41 +0100 |
commit | c847335ed683f633b78c243fc78a4c15c765c4e7 (patch) | |
tree | e724e2ccdab723b11b01691e43aa0f37da20414f /app/models/repository.rb | |
parent | fabc3d7bdec27a45349c5c6f38683ca5c6fe8817 (diff) | |
download | gitlab-ce-c847335ed683f633b78c243fc78a4c15c765c4e7.tar.gz |
Don't execute git hooks if you create branch as part of other changeidea-to-production-demo
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.
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 4da1933c189..ff7f1a3d638 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -143,14 +143,18 @@ class Repository tags.find { |tag| tag.name == name } end - def add_branch(user, branch_name, target) + def add_branch(user, branch_name, target, with_hooks: true) oldrev = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + branch_name target = commit(target).try(:id) return false unless target - GitHooksService.new.execute(user, path_to_repo, oldrev, target, ref) do + if with_hooks + GitHooksService.new.execute(user, path_to_repo, oldrev, target, ref) do + update_ref!(ref, target, oldrev) + end + else update_ref!(ref, target, oldrev) end |