diff options
| author | Stan Hu <stanhu@gmail.com> | 2018-09-13 19:08:07 +0000 |
|---|---|---|
| committer | Stan Hu <stanhu@gmail.com> | 2018-09-13 19:08:07 +0000 |
| commit | 3cd6939527525f8d191bc0ae519059b4e3a492ad (patch) | |
| tree | b36b9c35e13c8ebef3c6af1276dff80799fcbcb4 /lib | |
| parent | 35807fa052fed36228991a41b78a1ca09f4f0601 (diff) | |
| parent | 14738fae29d5b89d558613bb603e416a9d0ccc07 (diff) | |
| download | gitlab-shell-3cd6939527525f8d191bc0ae519059b4e3a492ad.tar.gz | |
Merge branch 'ash.mckenzie/display-feedback' into 'master'
Display helpful feedback when proxying an SSH git push to secondary request
See merge request gitlab-org/gitlab-shell!244
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/action/custom.rb | 10 | ||||
| -rw-r--r-- | lib/http_helper.rb | 3 |
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) |
