Skip to content

Commit c644116

Browse files
committed
Merge branch '83-follow-up-from-handle-gl_repository-env-variable-and-use-it-in-api-calls' into 'master'
Use gl_repository if present when enqueing Sidekiq PostReceive jobs Closes #83 See merge request !132
2 parents db96f72 + be835f9 commit c644116

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v5.0.5
2+
- Use gl_repository if present when enqueing Sidekiq PostReceive jobs
3+
14
v5.0.4
25
- Handle GL_REPOSITORY env variable and use it in API calls and Sidekiq enqueuing
36

lib/gitlab_post_receive.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def print_broadcast_message(message)
107107
def update_redis
108108
# Encode changes as base64 so we don't run into trouble with non-UTF-8 input.
109109
changes = Base64.encode64(@changes)
110-
# TODO: Change to `@gl_repository || @repo_path` in next release.
110+
# TODO: Change to `@gl_repository` in next release.
111111
# See https://gitlab.com/gitlab-org/gitlab-shell/merge_requests/130#note_28747613
112-
project_identifier = @repo_path
112+
project_identifier = @gl_repository || @repo_path
113113

114114
queue = "#{config.redis_namespace}:queue:post_receive"
115115
msg = JSON.dump({

spec/gitlab_post_receive_spec.rb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,28 @@
137137
end
138138
end
139139

140-
it "pushes a Sidekiq job onto the queue" do
141-
expect(redis_client).to receive(:rpush).with(
142-
'resque:gitlab:queue:post_receive',
143-
%Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}","enqueued_at":#{enqueued_at.to_f}}/
144-
).and_return(true)
140+
context 'Sidekiq jobs' do
141+
it "pushes a Sidekiq job onto the queue" do
142+
expect(redis_client).to receive(:rpush).with(
143+
'resque:gitlab:queue:post_receive',
144+
%Q/{"class":"PostReceive","args":["#{gl_repository}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}","enqueued_at":#{enqueued_at.to_f}}/
145+
).and_return(true)
145146

146-
gitlab_post_receive.exec
147+
gitlab_post_receive.exec
148+
end
149+
150+
context 'when gl_repository is nil' do
151+
let(:gl_repository) { nil }
152+
153+
it "pushes a Sidekiq job with the repository path" do
154+
expect(redis_client).to receive(:rpush).with(
155+
'resque:gitlab:queue:post_receive',
156+
%Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}","enqueued_at":#{enqueued_at.to_f}}/
157+
).and_return(true)
158+
159+
gitlab_post_receive.exec
160+
end
161+
end
147162
end
148163

149164
context 'reference counter' do

0 commit comments

Comments
 (0)