summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-05-30 22:45:54 -0400
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-05-30 22:45:54 -0400
commitbe835f93c593e2545e2172983bdf92e059099a29 (patch)
tree047323e5c22ebbfa4177ae6cb692d8cfa7ad16ee
parentdb96f7244f52842798e2fb4261677838d2766162 (diff)
downloadgitlab-shell-be835f93c593e2545e2172983bdf92e059099a29.tar.gz
Use gl_repository if present when enqueing Sidekiq PostReceive jobs83-follow-up-from-handle-gl_repository-env-variable-and-use-it-in-api-calls
-rw-r--r--CHANGELOG3
-rw-r--r--lib/gitlab_post_receive.rb4
-rw-r--r--spec/gitlab_post_receive_spec.rb27
3 files changed, 26 insertions, 8 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b9a20b3..6b543ec 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v5.0.5
+ - Use gl_repository if present when enqueing Sidekiq PostReceive jobs
+
v5.0.4
- Handle GL_REPOSITORY env variable and use it in API calls and Sidekiq enqueuing
diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb
index e987019..00a1b1b 100644
--- a/lib/gitlab_post_receive.rb
+++ b/lib/gitlab_post_receive.rb
@@ -107,9 +107,9 @@ class GitlabPostReceive
def update_redis
# Encode changes as base64 so we don't run into trouble with non-UTF-8 input.
changes = Base64.encode64(@changes)
- # TODO: Change to `@gl_repository || @repo_path` in next release.
+ # TODO: Change to `@gl_repository` in next release.
# See https://gitlab.com/gitlab-org/gitlab-shell/merge_requests/130#note_28747613
- project_identifier = @repo_path
+ project_identifier = @gl_repository || @repo_path
queue = "#{config.redis_namespace}:queue:post_receive"
msg = JSON.dump({
diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb
index 3efdcb9..69e19e6 100644
--- a/spec/gitlab_post_receive_spec.rb
+++ b/spec/gitlab_post_receive_spec.rb
@@ -137,13 +137,28 @@ describe GitlabPostReceive do
end
end
- it "pushes a Sidekiq job onto the queue" do
- expect(redis_client).to receive(:rpush).with(
- 'resque:gitlab:queue:post_receive',
- %Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}","enqueued_at":#{enqueued_at.to_f}}/
- ).and_return(true)
+ context 'Sidekiq jobs' do
+ it "pushes a Sidekiq job onto the queue" do
+ expect(redis_client).to receive(:rpush).with(
+ 'resque:gitlab:queue:post_receive',
+ %Q/{"class":"PostReceive","args":["#{gl_repository}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}","enqueued_at":#{enqueued_at.to_f}}/
+ ).and_return(true)
- gitlab_post_receive.exec
+ gitlab_post_receive.exec
+ end
+
+ context 'when gl_repository is nil' do
+ let(:gl_repository) { nil }
+
+ it "pushes a Sidekiq job with the repository path" do
+ expect(redis_client).to receive(:rpush).with(
+ 'resque:gitlab:queue:post_receive',
+ %Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}","enqueued_at":#{enqueued_at.to_f}}/
+ ).and_return(true)
+
+ gitlab_post_receive.exec
+ end
+ end
end
context 'reference counter' do