Skip to content
Snippets Groups Projects
Verified Commit 95b84e2c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Move branch creation logic in service

parent 8f3701ef
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment