summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2016-07-18 17:06:49 +0300
committerValery Sizov <valery@gitlab.com>2016-07-18 17:06:49 +0300
commitb5038025ff0ab641384569d7588b878251f6e0d6 (patch)
tree6be17422b1d7790540b7e4d30ea925605c34082e /app/services
parent017ae313dc84682e260e960f93fb4a55af0df523 (diff)
downloadgitlab-ce-backport_from_ee_easy_commit_creation.tar.gz
Fix of 'Commits being passed to custom hooks are already reachable when using the UI'backport_from_ee_easy_commit_creation
Diffstat (limited to 'app/services')
-rw-r--r--app/services/create_branch_service.rb28
1 files changed, 13 insertions, 15 deletions
diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb
index d874582d54f..757fc35a78f 100644
--- a/app/services/create_branch_service.rb
+++ b/app/services/create_branch_service.rb
@@ -15,21 +15,19 @@ class CreateBranchService < BaseService
return error('Branch already exists')
end
- new_branch = nil
-
- if source_project != @project
- repository.with_tmp_ref do |tmp_ref|
- repository.fetch_ref(
- source_project.repository.path_to_repo,
- "refs/heads/#{ref}",
- tmp_ref
- )
-
- new_branch = repository.add_branch(current_user, branch_name, tmp_ref)
- end
- else
- new_branch = repository.add_branch(current_user, branch_name, ref)
- end
+ new_branch = if source_project != @project
+ repository.fetch_ref(
+ source_project.repository.path_to_repo,
+ "refs/heads/#{ref}",
+ "refs/heads/#{branch_name}"
+ )
+
+ repository.after_create_branch
+
+ repository.find_branch(branch_name)
+ else
+ repository.add_branch(current_user, branch_name, ref)
+ end
if new_branch
success(new_branch)