class Git::CommandLine

def run(*args, out: nil, err: nil, normalize:, chomp:, merge:, chdir: nil, timeout: nil)

Raises:
  • (Git::TimeoutError) - if the command times out
  • (Git::ProcessIOError) - if an exception was raised while collecting subprocess output
  • (Git::FailedError) - if the command returned a non-zero exitstatus
  • (Git::SignaledError) - if the command was terminated because of an uncaught signal
  • (ArgumentError) - if `args` is not an array of strings

Returns:
  • (Git::CommandLineResult) - the output of the command

Parameters:
  • timeout (Numeric, nil) -- the maximum seconds to wait for the command to complete
  • chdir (String) -- the directory to run the command in
  • merge (Boolean) -- whether to merge stdout and stderr in the string returned
  • chomp (Boolean) -- whether to chomp the output
  • normalize (Boolean) -- whether to normalize the output to a valid encoding
  • err (#write) -- the object to write stderr to or nil to ignore stderr
  • out (#write, nil) -- the object to write stdout to or nil to ignore stdout
  • args (Array) -- the command line arguements to pass to git

Other tags:
    Example: Capture stderr in a StringIO object -
    Example: Capture stdout in a temporary file -
    Example: Run a command and without normalizing the output -
    Example: Run a command and return the chomped output -
    Example: The args array should be splatted into the parameter list -
    Example: Run a command and return the output -
def run(*args, out: nil, err: nil, normalize:, chomp:, merge:, chdir: nil, timeout: nil)
  git_cmd = build_git_cmd(args)
  begin
    result = ProcessExecuter.run(env, *git_cmd, out: out, err: err, merge:, chdir: (chdir || :not_set), timeout: timeout, raise_errors: false)
  rescue ProcessExecuter::Command::ProcessIOError => e
    raise Git::ProcessIOError.new(e.message), cause: e.exception.cause
  end
  process_result(result, normalize, chomp, timeout)
end