Simply give result if result[:status] == :error

This commit is contained in:
Lin Jen-Shin 2016-12-08 15:31:42 +08:00
parent cf677378ee
commit 691f1c4968

View file

@ -1,8 +1,9 @@
class CreateBranchService < BaseService
def execute(branch_name, ref)
failure = validate_new_branch(branch_name)
result = ValidateNewBranchService.new(project, current_user).
execute(branch_name)
return failure if failure
return result if result[:status] == :error
new_branch = repository.add_branch(current_user, branch_name, ref)
@ -18,13 +19,4 @@ class CreateBranchService < BaseService
def success(branch)
super().merge(branch: branch)
end
private
def validate_new_branch(branch_name)
result = ValidateNewBranchService.new(project, current_user).
execute(branch_name)
error(result[:message]) if result[:status] == :error
end
end