From 08e4d98cacb12f3d9b80b81ed1f50b9474c8b276 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Mon, 6 Feb 2017 18:59:54 +0200 Subject: Create master branch first if project is repository-less --- app/services/create_branch_service.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/services') diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb index 77459d8779d..b07338d500a 100644 --- a/app/services/create_branch_service.rb +++ b/app/services/create_branch_service.rb @@ -1,5 +1,7 @@ class CreateBranchService < BaseService def execute(branch_name, ref) + create_master_branch if project.empty_repo? + result = ValidateNewBranchService.new(project, current_user) .execute(branch_name) @@ -19,4 +21,16 @@ class CreateBranchService < BaseService def success(branch) super().merge(branch: branch) end + + private + + def create_master_branch + project.repository.commit_file( + current_user, + '/README.md', + '', + message: 'Add README.md', + branch_name: 'master', + update: false) + end end -- cgit v1.2.1