diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-03-01 12:08:51 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-03-01 12:25:21 -0600 |
commit | 80543e0abd65a575bcc43f2482279af3980f4acc (patch) | |
tree | a9ca8ff8543f565bfd3a41a949f57ef39593b2b7 /app/services/files | |
parent | 981c730fdb3da1ada8d1b44d21e75a11175b3026 (diff) | |
download | gitlab-ce-80543e0abd65a575bcc43f2482279af3980f4acc.tar.gz |
Fix creating a file in an empty repo using the API
Diffstat (limited to 'app/services/files')
-rw-r--r-- | app/services/files/base_service.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb index 31869c2f01e..3480cb70f67 100644 --- a/app/services/files/base_service.rb +++ b/app/services/files/base_service.rb @@ -58,16 +58,12 @@ module Files raise_error("You are not allowed to push into this branch") end - unless project.empty_repo? - unless @start_project.repository.branch_exists?(@start_branch) - raise_error('You can only create or edit files when you are on a branch') - end - - if different_branch? - if repository.branch_exists?(@target_branch) - raise_error('Branch with such name already exists. You need to switch to this branch in order to make changes') - end - end + if !@start_project.empty_repo? && !@start_project.repository.branch_exists?(@start_branch) + raise ValidationError, 'You can only create or edit files when you are on a branch' + end + + if !project.empty_repo? && different_branch? && repository.branch_exists?(@branch_name) + raise ValidationError, 'Branch with such name already exists. You need to switch to this branch in order to make changes' end end |