Commit 691f1c49 authored by Lin Jen-Shin's avatar Lin Jen-Shin

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

parent cf677378
class CreateBranchService < BaseService class CreateBranchService < BaseService
def execute(branch_name, ref) 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) new_branch = repository.add_branch(current_user, branch_name, ref)
...@@ -18,13 +19,4 @@ class CreateBranchService < BaseService ...@@ -18,13 +19,4 @@ class CreateBranchService < BaseService
def success(branch) def success(branch)
super().merge(branch: branch) super().merge(branch: branch)
end 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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment