diff options
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r-- | lib/api/internal.rb | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 70b32f7d758..224aaaaf006 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -15,6 +15,12 @@ module API status code { status: success, message: message }.merge(extra_options).compact end + + def lfs_authentication_url(project) + # This is a separate method so that EE can alter its behaviour more + # easily. + project.http_url_to_repo + end end namespace 'internal' do @@ -53,7 +59,7 @@ module API actor end - access_checker_klass = wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess + access_checker_klass = repo_type.access_checker_class access_checker = access_checker_klass.new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities, namespace_path: namespace_path, project_path: project_path, @@ -81,12 +87,8 @@ module API gl_id: Gitlab::GlId.gl_id(user), gl_username: user&.username, git_config_options: [], - - # This repository_path is a bogus value but gitlab-shell still requires - # its presence. https://gitlab.com/gitlab-org/gitlab-shell/issues/135 - repository_path: '/', - - gitaly: gitaly_payload(params[:action]) + gitaly: gitaly_payload(params[:action]), + gl_console_messages: check_result.console_messages } # Custom option for git-receive-pack command @@ -118,7 +120,9 @@ module API raise ActiveRecord::RecordNotFound.new("No key_id or user_id passed!") end - Gitlab::LfsToken.new(actor).authentication_payload(project.http_url_to_repo) + Gitlab::LfsToken + .new(actor) + .authentication_payload(lfs_authentication_url(project)) end # rubocop: enable CodeReuse/ActiveRecord @@ -252,19 +256,25 @@ module API post '/post_receive' do status 200 + output = {} # Messages to gitlab-shell + user = identify(params[:identifier]) + project = Gitlab::GlRepository.parse(params[:gl_repository]).first + push_options = Gitlab::PushOptions.new(params[:push_options]) + PostReceive.perform_async(params[:gl_repository], params[:identifier], - params[:changes], params[:push_options].to_a) + params[:changes], push_options.as_json) + + mr_options = push_options.get(:merge_request) + output.merge!(process_mr_push_options(mr_options, project, user, params[:changes])) if mr_options.present? + broadcast_message = BroadcastMessage.current&.last&.message reference_counter_decreased = Gitlab::ReferenceCounter.new(params[:gl_repository]).decrease - output = { - merge_request_urls: merge_request_urls, + output.merge!( broadcast_message: broadcast_message, - reference_counter_decreased: reference_counter_decreased - } - - project = Gitlab::GlRepository.parse(params[:gl_repository]).first - user = identify(params[:identifier]) + reference_counter_decreased: reference_counter_decreased, + merge_request_urls: merge_request_urls + ) # A user is not guaranteed to be returned; an orphaned write deploy # key could be used |