Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-03-01 21:08:51 +0300
committerDouwe Maan <douwe@selenight.nl>2017-03-01 21:25:21 +0300
commit80543e0abd65a575bcc43f2482279af3980f4acc (patch)
treea9ca8ff8543f565bfd3a41a949f57ef39593b2b7 /app/services/files
parent981c730fdb3da1ada8d1b44d21e75a11175b3026 (diff)
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.rb16
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