summaryrefslogtreecommitdiff
path: root/lib/gitlab/git_access.rb
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-01-25 12:26:52 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-02-06 13:35:35 +0000
commite42a548f1dac02577d0c1731fef508dab68c45a5 (patch)
tree9781b82ec0da58683ebeb0fd0ba2062a9ce10e43 /lib/gitlab/git_access.rb
parentbc78ae6985ee37f9ac2ffc2dbf6f445078d16038 (diff)
downloadgitlab-ce-e42a548f1dac02577d0c1731fef508dab68c45a5.tar.gz
Move new project on push logic to a service
Diffstat (limited to 'lib/gitlab/git_access.rb')
-rw-r--r--lib/gitlab/git_access.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 38649a4fdef..32a2395a26b 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -4,6 +4,7 @@ module Gitlab
class GitAccess
UnauthorizedError = Class.new(StandardError)
NotFoundError = Class.new(StandardError)
+ ProjectCreationError = Class.new(StandardError)
ProjectMovedError = Class.new(NotFoundError)
ERROR_MESSAGES = {
@@ -13,13 +14,13 @@ module Gitlab
'This deploy key does not have write access to this project.',
no_repo: 'A repository for this project does not exist yet.',
project_not_found: 'The project you were looking for could not be found.',
- namespace_not_found: 'The namespace you were looking for could not be found.',
account_blocked: 'Your account has been blocked.',
command_not_allowed: "The command you're trying to execute is not allowed.",
upload_pack_disabled_over_http: 'Pulling over HTTP is not allowed.',
receive_pack_disabled_over_http: 'Pushing over HTTP is not allowed.',
read_only: 'The repository is temporarily read-only. Please try again later.',
- cannot_push_to_read_only: "You can't push code to a read-only GitLab instance."
+ cannot_push_to_read_only: "You can't push code to a read-only GitLab instance.",
+ namespace_not_found: 'The namespace you were looking for could not be found.'
}.freeze
DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive }.freeze
@@ -52,7 +53,7 @@ module Gitlab
check_download_access!
when *PUSH_COMMANDS
check_push_access!(cmd, changes)
- check_namespace_accessibility!(cmd)
+ check_namespace_accessibility!
end
true
@@ -148,7 +149,7 @@ module Gitlab
end
end
- def check_namespace_accessibility!(cmd)
+ def check_namespace_accessibility!
return unless project.blank?
unless target_namespace
@@ -248,7 +249,7 @@ module Gitlab
end
def can_create_project_in_namespace?(cmd)
- return false unless PUSH_COMMANDS.include?(cmd) && target_namespace
+ return false unless push?(cmd) && target_namespace
user.can?(:create_projects, target_namespace)
end
@@ -265,6 +266,10 @@ module Gitlab
command == 'git-receive-pack'
end
+ def push?(cmd)
+ PUSH_COMMANDS.include?(cmd)
+ end
+
def upload_pack_disabled_over_http?
!Gitlab.config.gitlab_shell.upload_pack
end