diff options
author | Valery Sizov <valery@gitlab.com> | 2017-02-06 18:59:54 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-02-23 15:31:03 +0200 |
commit | 08e4d98cacb12f3d9b80b81ed1f50b9474c8b276 (patch) | |
tree | 69376ef4e4553a378c65ff33bb3776ff5d4bebd3 /app/services/create_branch_service.rb | |
parent | 319dfd68a82fe0b6893513a8f99962c3ea13965b (diff) | |
download | gitlab-ce-08e4d98cacb12f3d9b80b81ed1f50b9474c8b276.tar.gz |
Create master branch first if project is repository-less
Diffstat (limited to 'app/services/create_branch_service.rb')
-rw-r--r-- | app/services/create_branch_service.rb | 14 |
1 files changed, 14 insertions, 0 deletions
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 |