Simply give result if result[:status] == :error
This commit is contained in:
parent
cf677378ee
commit
691f1c4968
|
@ -1,8 +1,9 @@
|
||||||
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
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue