diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-04-15 02:46:55 +0000 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-04-15 02:46:55 +0000 |
commit | 2f35ba98fae6e0b58b196e3fbbe00e6ee703cbe8 (patch) | |
tree | b67a98e00b59bd1a785ffb3fdccf0336c6c92d7d /lib/api/internal.rb | |
parent | e22bd9650d7bebfea0909fdaf5be7dcf746b53f7 (diff) | |
parent | 309bab431075eabfb7a01300f946ce9eb5b6fb98 (diff) | |
download | gitlab-ce-2f35ba98fae6e0b58b196e3fbbe00e6ee703cbe8.tar.gz |
Merge branch 'master' into 'add-sentry-js-again-with-vue'
# Conflicts:
# app/views/layouts/_head.html.haml
# config/webpack.config.js
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r-- | lib/api/internal.rb | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 523f38d129e..215bc03d0e9 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -11,14 +11,16 @@ module API # Params: # key_id - ssh key id for Git over SSH # user_id - user id for Git over HTTP + # protocol - Git access protocol being used, e.g. HTTP or SSH # project - project path with namespace # action - git action (git-upload-pack or git-receive-pack) - # ref - branch name - # forced_push - forced_push - # protocol - Git access protocol being used, e.g. HTTP or SSH + # changes - changes as "oldrev newrev ref", see Gitlab::ChangesList post "/allowed" do status 200 + # Stores some Git-specific env thread-safely + Gitlab::Git::Env.set(parse_env) + actor = if params[:key_id] Key.find_by(id: params[:key_id]) @@ -30,18 +32,10 @@ module API actor.update_last_used_at if actor.is_a?(Key) - access = - if wiki? - Gitlab::GitAccessWiki.new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities) - else - Gitlab::GitAccess.new(actor, - project, - protocol, - authentication_abilities: ssh_authentication_abilities, - env: parse_allowed_environment_variables) - end - - access_status = access.check(params[:action], params[:changes]) + access_checker = wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess + access_status = access_checker + .new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities) + .check(params[:action], params[:changes]) response = { status: access_status.status, message: access_status.message } @@ -138,8 +132,11 @@ module API return unless Gitlab::GitalyClient.enabled? + relative_path = Gitlab::RepoPath.strip_storage_path(params[:repo_path]) + project = Project.find_by_full_path(relative_path.sub(/\.(git|wiki)\z/, '')) + begin - Gitlab::GitalyClient::Notifications.new(params[:repo_path]).post_receive + Gitlab::GitalyClient::Notifications.new(project.repository).post_receive rescue GRPC::Unavailable => e render_api_error(e, 500) end |