summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/action/custom.rb10
-rw-r--r--lib/http_helper.rb3
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/action/custom.rb b/lib/action/custom.rb
index c781f00..328a12f 100644
--- a/lib/action/custom.rb
+++ b/lib/action/custom.rb
@@ -54,6 +54,8 @@ module Action
raise UnsuccessfulError, 'Response was not valid JSON'
end
+ inform_client(body['message']) if body['message']
+
print_flush(body['result'])
# In the context of the git push sequence of events, it's necessary to read
@@ -90,8 +92,12 @@ module Action
def print_flush(str)
return false unless str
- print(Base64.decode64(str))
- STDOUT.flush
+ $stdout.print(Base64.decode64(str))
+ $stdout.flush
+ end
+
+ def inform_client(str)
+ $stderr.puts(str)
end
def validate!
diff --git a/lib/http_helper.rb b/lib/http_helper.rb
index a7e7b23..ac18f49 100644
--- a/lib/http_helper.rb
+++ b/lib/http_helper.rb
@@ -83,7 +83,8 @@ module HTTPHelper
$logger.info('finished HTTP request', method: method.to_s.upcase, url: url, duration: Time.new - start_time)
end
- if response.code == "200"
+ case response
+ when Net::HTTPSuccess, Net::HTTPMultipleChoices
$logger.debug('Received response', code: response.code, body: response.body)
else
$logger.error('Call failed', method: method.to_s.upcase, url: url, code: response.code, body: response.body)