Commit dfb1dac6 authored by Luke Duncalfe's avatar Luke Duncalfe

Allow GitlabPostReceive to print warnings

Warnings are printed using the same method that prints broadcast
messages. This ensures that whatever warnings are returned will be
displayed correctly.
parent 8f8c5156
...@@ -28,6 +28,7 @@ class GitlabPostReceive ...@@ -28,6 +28,7 @@ class GitlabPostReceive
print_merge_request_links(response['merge_request_urls']) if response['merge_request_urls'] print_merge_request_links(response['merge_request_urls']) if response['merge_request_urls']
puts response['redirected_message'] if response['redirected_message'] puts response['redirected_message'] if response['redirected_message']
puts response['project_created_message'] if response['project_created_message'] puts response['project_created_message'] if response['project_created_message']
print_warnings(response['warnings']) if response['warnings']
response['reference_counter_decreased'] response['reference_counter_decreased']
rescue GitlabNet::ApiUnreachableError rescue GitlabNet::ApiUnreachableError
...@@ -59,6 +60,11 @@ class GitlabPostReceive ...@@ -59,6 +60,11 @@ class GitlabPostReceive
puts puts
end end
def print_warnings(warnings)
message = "WARNINGS:\n#{warnings}"
print_broadcast_message(message)
end
def print_broadcast_message(message) def print_broadcast_message(message)
# A standard terminal window is (at least) 80 characters wide. # A standard terminal window is (at least) 80 characters wide.
total_width = 80 total_width = 80
......
...@@ -96,7 +96,21 @@ describe GitlabPostReceive do ...@@ -96,7 +96,21 @@ describe GitlabPostReceive do
expect(gitlab_post_receive.exec).to eq(true) expect(gitlab_post_receive.exec).to eq(true)
end end
end end
end
context 'when warnings available' do
let(:response) do
{
'reference_counter_decreased' => true,
'warnings' => 'My warning message'
}
end
it 'prints warnings the same ways as broadcast messages' do
expect_any_instance_of(GitlabNet).to receive(:post_receive).and_return(response)
expect(gitlab_post_receive).to receive(:print_broadcast_message).with("WARNINGS:\nMy warning message")
expect(gitlab_post_receive.exec).to eq(true)
end
end end
context 'when redirected message available' do context 'when redirected message available' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment