summaryrefslogtreecommitdiff
path: root/lib/api/internal.rb
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-04-28 13:52:09 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-05-03 17:37:30 -0300
commitc45341c816d78d51aee84a6068d778b9cbc502c8 (patch)
tree769202931229d2e799bdd0f4a8d7c6e8f9ba8ff8 /lib/api/internal.rb
parentc1e2da9293bb036280c05ee6b99952b067bdc316 (diff)
downloadgitlab-ce-c45341c816d78d51aee84a6068d778b9cbc502c8.tar.gz
Generate and handle a gl_repository param to pass around components
This new param allows us to share project information between components that don't share or don't have access to the same filesystem mountpoints, for example between Gitaly and Rails or between Rails and Gitlab-Shell hooks. The previous parameters are still supported, but if found, gl_repository is prefered. The old parameters should be deprecated once all components support the new format.
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r--lib/api/internal.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index ebed26dd178..ddb2047f686 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -42,6 +42,10 @@ module API
if access_status.status
log_user_activity(actor)
+ # Project id to pass between components that don't share/don't have
+ # access to the same filesystem mounts
+ response[:gl_repository] = "#{wiki? ? 'wiki' : 'project'}-#{project.id}"
+
# Return the repository full path so that gitlab-shell has it when
# handling ssh commands
response[:repository_path] =
@@ -134,11 +138,9 @@ 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(project.repository).post_receive
+ repository = wiki? ? project.wiki.repository : project.repository
+ Gitlab::GitalyClient::Notifications.new(repository.raw_repository).post_receive
rescue GRPC::Unavailable => e
render_api_error!(e, 500)
end