summaryrefslogtreecommitdiff
path: root/app/controllers/projects/git_http_controller.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-03-24 18:58:29 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-03-24 18:58:29 +0100
commit5fe06d7365f5552904add8027309d6216954793e (patch)
treec245c6270c0599c036c16032c5a27f7e25e3dff1 /app/controllers/projects/git_http_controller.rb
parent5f3708418ab71c47c6fffe63b1fac03c0e7c889f (diff)
downloadgitlab-ce-5fe06d7365f5552904add8027309d6216954793e.tar.gz
Add some upload specs
Diffstat (limited to 'app/controllers/projects/git_http_controller.rb')
-rw-r--r--app/controllers/projects/git_http_controller.rb36
1 files changed, 29 insertions, 7 deletions
diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb
index 129e87dbf13..a26ab736115 100644
--- a/app/controllers/projects/git_http_controller.rb
+++ b/app/controllers/projects/git_http_controller.rb
@@ -5,10 +5,12 @@ class Projects::GitHttpController < Projects::ApplicationController
def git_rpc
if upload_pack? && upload_pack_allowed?
- render_ok and return
+ render_ok
+ elsif receive_pack? && receive_pack_allowed?
+ render_ok
+ else
+ render_not_found
end
-
- render_not_found
end
%i{info_refs git_receive_pack git_upload_pack}.each do |method|
@@ -30,7 +32,7 @@ class Projects::GitHttpController < Projects::ApplicationController
end
def project_found?
- render_not_found if project.nil?
+ render_not_found if project.blank?
end
def ci_request?(login, password)
@@ -124,13 +126,21 @@ class Projects::GitHttpController < Projects::ApplicationController
end
def upload_pack?
+ rpc == 'git-upload-pack'
+ end
+
+ def receive_pack?
+ rpc == 'git-receive-pack'
+ end
+
+ def rpc
if action_name == 'info_refs'
- params[:service] == 'git-upload-pack'
+ params[:service]
else
- action_name == 'git_upload_pack'
+ action_name.gsub('_', '-')
end
end
-
+
def render_ok
render json: {
'GL_ID' => Gitlab::ShellEnv.gl_id(@user),
@@ -164,4 +174,16 @@ class Projects::GitHttpController < Projects::ApplicationController
false
end
end
+
+ def receive_pack_allowed?
+ if !Gitlab.config.gitlab_shell.receive_pack
+ false
+ elsif user
+ # Skip user authorization on upload request.
+ # It will be done by the pre-receive hook in the repository.
+ true
+ else
+ false
+ end
+ end
end