Commit 95b84e2c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Move branch creation logic in service

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 8f3701ef
......@@ -16,11 +16,7 @@ class Projects::BranchesController < Projects::ApplicationController
end
def create
@repository.add_branch(params[:branch_name], params[:ref])
if new_branch = @repository.find_branch(params[:branch_name])
Event.create_ref_event(@project, current_user, new_branch, 'add')
end
CreateBranchService.new.execute(project, params[:branch_name], params[:ref], current_user)
redirect_to project_branches_path(@project)
end
......
class CreateBranchService
def execute(project, branch_name, ref, current_user)
repository = project.repository
repository.add_branch(branch_name, ref)
new_branch = repository.find_branch(branch_name)
if new_branch
Event.create_ref_event(project, current_user, new_branch, 'add')
end
new_branch
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