Class: RubyGit::CommandLine::Runner
- Inherits:
-
Object
- Object
- RubyGit::CommandLine::Runner
- Defined in:
- lib/ruby_git/command_line/runner.rb
Overview
Runs the git command line and returns the result
Instance Attribute Summary collapse
-
#binary_path ⇒ String
readonly
The path to the command line binary to run.
-
#env ⇒ Hash<String, String>
readonly
Variables to set (or unset) in the git command's environment.
-
#global_options ⇒ Array<String>
readonly
The global options to pass to git.
-
#logger ⇒ Logger
readonly
The logger to use for logging git commands and results.
Instance Method Summary collapse
-
#call(*args, **options_hash) ⇒ RubyGit::CommandLine::Result
Execute a git command, wait for it to finish, and return the result.
-
#initialize(env, binary_path, global_options, logger) ⇒ Runner
constructor
Create a an object to run git commands via the command line.
Constructor Details
#initialize(env, binary_path, global_options, logger) ⇒ Runner
Create a an object to run git commands via the command line
32 33 34 35 36 37 |
# File 'lib/ruby_git/command_line/runner.rb', line 32 def initialize(env, binary_path, , logger) @env = env @binary_path = binary_path @global_options = @logger = logger end |
Instance Attribute Details
#binary_path ⇒ String (readonly)
The path to the command line binary to run
66 67 68 |
# File 'lib/ruby_git/command_line/runner.rb', line 66 def binary_path @binary_path end |
#env ⇒ Hash<String, String> (readonly)
Variables to set (or unset) in the git command's environment
53 54 55 |
# File 'lib/ruby_git/command_line/runner.rb', line 53 def env @env end |
#global_options ⇒ Array<String> (readonly)
The global options to pass to git
These are options that are passed to git before the command name and
arguments. For example, in git --git-dir /path/to/git/dir version
, the
global options are %w[--git-dir /path/to/git/dir].
85 86 87 |
# File 'lib/ruby_git/command_line/runner.rb', line 85 def @global_options end |
#logger ⇒ Logger (readonly)
The logger to use for logging git commands and results
100 101 102 |
# File 'lib/ruby_git/command_line/runner.rb', line 100 def logger @logger end |
Instance Method Details
#call(*args, **options_hash) ⇒ RubyGit::CommandLine::Result
Execute a git command, wait for it to finish, and return the result
NORMALIZATION
The command output is returned as a Unicde string containing the binary output from the command. If the binary output is not valid UTF-8, the output will cause problems because the encoding will be invalid.
Normalization is a process that trys to convert the binary output to a valid
UTF-8 string. It uses the rchardet
gem to detect the encoding of the binary
output and then converts it to UTF-8.
Normalization is not enabled by default. Pass normalize: true
to RubyGit::CommandLine#run
to enable it. Normalization will only be performed on stdout and only if the out:
` option
is nil or is a StringIO object. If the out: option is set to a file or other IO object,
the normalize option will be ignored.
167 168 169 170 171 |
# File 'lib/ruby_git/command_line/runner.rb', line 167 def call(*args, **) = RubyGit::CommandLine::Options.new(logger: logger, **) result = run(*args, ) process_result(result, ) end |