Skip to content

Commit ac8bbb9

Browse files
author
Mayra Cabrera
committed
Prints a message if project was redirected
1 parent 76e7554 commit ac8bbb9

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/gitlab_post_receive.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def exec
2525
end
2626

2727
return false unless response
28-
2928
print_broadcast_message(response['broadcast_message']) if response['broadcast_message']
3029
print_merge_request_links(response['merge_request_urls']) if response['merge_request_urls']
30+
puts response['redirected_message'] if response['redirected_message']
3131

3232
response['reference_counter_decreased']
3333
rescue GitlabNet::ApiUnreachableError

spec/gitlab_post_receive_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,30 @@
206206
expect(gitlab_post_receive.exec).to eq(true)
207207
end
208208
end
209+
210+
context 'when redirected message available' do
211+
let(:message) do
212+
<<-MSG
213+
Project 'foo/bar' was moved to 'foo/baz'.
214+
215+
Please update your Git remote:
216+
217+
git remote set-url origin http://localhost:3000/foo/baz.git
218+
MSG
219+
end
220+
let(:response) do
221+
{
222+
'reference_counter_decreased' => true,
223+
'redirected_message' => message
224+
}
225+
end
226+
227+
it 'prints redirected message' do
228+
expect_any_instance_of(GitlabNet).to receive(:post_receive).and_return(response)
229+
assert_redirected_message_printed(gitlab_post_receive)
230+
expect(gitlab_post_receive.exec).to eq(true)
231+
end
232+
end
209233
end
210234
end
211235

@@ -252,4 +276,15 @@ def assert_broadcast_message_printed(gitlab_post_receive)
252276
"========================================================================"
253277
).ordered
254278
end
279+
280+
def assert_redirected_message_printed(gitlab_post_receive)
281+
message = <<-MSG
282+
Project 'foo/bar' was moved to 'foo/baz'.
283+
284+
Please update your Git remote:
285+
286+
git remote set-url origin http://localhost:3000/foo/baz.git
287+
MSG
288+
expect(gitlab_post_receive).to receive(:puts).with(message).ordered
289+
end
255290
end

0 commit comments

Comments
 (0)