diff options
author | Valery Sizov <valery@gitlab.com> | 2016-07-06 16:26:59 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-07-06 20:58:43 +0300 |
commit | 3baed8cb6ddf9d46b653f17135cbffc8e662cedd (patch) | |
tree | 836cdccc6609d1d9d3a8ba52c76dadc6267fd738 /app/services/create_branch_service.rb | |
parent | cfd5870b62e9d76e564ffc64db1d1281b4a363bb (diff) | |
download | gitlab-ce-3baed8cb6ddf9d46b653f17135cbffc8e662cedd.tar.gz |
Services: code style fixes, minor refactoringservices_refactoring1
Diffstat (limited to 'app/services/create_branch_service.rb')
-rw-r--r-- | app/services/create_branch_service.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb index cc128563437..d874582d54f 100644 --- a/app/services/create_branch_service.rb +++ b/app/services/create_branch_service.rb @@ -3,17 +3,20 @@ require_relative 'base_service' class CreateBranchService < BaseService def execute(branch_name, ref, source_project: @project) valid_branch = Gitlab::GitRefValidator.validate(branch_name) - if valid_branch == false + + unless valid_branch return error('Branch name is invalid') end repository = project.repository existing_branch = repository.find_branch(branch_name) + if existing_branch return error('Branch already exists') end new_branch = nil + if source_project != @project repository.with_tmp_ref do |tmp_ref| repository.fetch_ref( @@ -29,7 +32,6 @@ class CreateBranchService < BaseService end if new_branch - # GitPushService handles execution of services and hooks for branch pushes success(new_branch) else error('Invalid reference name') @@ -39,8 +41,6 @@ class CreateBranchService < BaseService end def success(branch) - out = super() - out[:branch] = branch - out + super().merge(branch: branch) end end |