summaryrefslogtreecommitdiff
path: root/lib/gitlab_shell.rb
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-04-02 17:10:43 +1100
committerAsh McKenzie <amckenzie@gitlab.com>2019-04-04 13:32:30 +1100
commit02088137c28f7b822a7d979f985ca38f3e0583ef (patch)
treeff0751e80326c26d4f07a5bca17f0363c9ad8c1e /lib/gitlab_shell.rb
parent3a79ac9d615e492af0d3f1e9545262e2ecf162aa (diff)
downloadgitlab-shell-02088137c28f7b822a7d979f985ca38f3e0583ef.tar.gz
Use write_stderr instead of $stderr.puts
Diffstat (limited to 'lib/gitlab_shell.rb')
-rw-r--r--lib/gitlab_shell.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb
index 2cb76a8..c615805 100644
--- a/lib/gitlab_shell.rb
+++ b/lib/gitlab_shell.rb
@@ -6,8 +6,11 @@ require 'pathname'
require_relative 'gitlab_net'
require_relative 'gitlab_metrics'
require_relative 'action'
+require_relative 'console_helper'
class GitlabShell # rubocop:disable Metrics/ClassLength
+ include ConsoleHelper
+
class AccessDeniedError < StandardError; end
class DisallowedCommandError < StandardError; end
class InvalidRepositoryPathError < StandardError; end
@@ -82,18 +85,18 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
true
rescue GitlabNet::ApiUnreachableError
- $stderr.puts "GitLab: Failed to authorize your Git request: internal API unreachable"
+ write_stderr('Failed to authorize your Git request: internal API unreachable')
false
rescue AccessDeniedError => ex
$logger.warn('Access denied', command: origin_cmd, user: log_username)
- $stderr.puts "GitLab: #{ex.message}"
+ write_stderr(ex.message)
false
rescue DisallowedCommandError
$logger.warn('Denied disallowed command', command: origin_cmd, user: log_username)
- $stderr.puts "GitLab: Disallowed command"
+ write_stderr('Disallowed command')
false
rescue InvalidRepositoryPathError
- $stderr.puts "GitLab: Invalid repository path"
+ write_stderr('Invalid repository path')
false
rescue Action::Custom::BaseError => ex
$logger.warn('Custom action error', exception: ex.class, message: ex.message,