class Git::Config
The global configuration for this gem
@api public
Attributes
Sets the configuration options for the git executable, SSH, and timeout
@return [String] the configured value
Sets the SSH command to use for git operations
@return [String] the configured SSH command
Sets the timeout for git operations
@return [Integer] the configured timeout in seconds
Public Class Methods
Source
# File lib/git/config.rb, line 22 def self.instance @instance ||= new end
Returns the process-wide singleton {Git::Config} instance
All calls to {Git.configure}, {Git.config}, and the {Git::ExecutionContext} classes resolve global configuration through this method.
@example Read the configured binary path
Git::Config.instance.binary_path #=> "git"
@example Mutate the singleton (same as Git.configure { |c| … })
Git::Config.instance.binary_path = '/usr/local/bin/git'
@return [Git::Config] the singleton config object
Source
# File lib/git/config.rb, line 44 def initialize @binary_path = nil @git_ssh = nil @timeout = nil end
Public Instance Methods
Source
# File lib/git/config.rb, line 59 def binary_path @binary_path || (ENV.fetch('GIT_PATH', nil) && File.join(ENV.fetch('GIT_PATH', nil), 'git')) || 'git' end
Returns the git executable path
Uses an explicitly configured path first, then ‘GIT_PATH`, then `git`.
@example Read the default executable
Git::Config.instance.binary_path #=> "git"
@return [String] the git executable path
Source
# File lib/git/config.rb, line 72 def git_ssh @git_ssh || ENV.fetch('GIT_SSH', nil) end
Returns the SSH wrapper path used by git operations
Uses an explicitly configured wrapper path first, then ‘GIT_SSH`.
@example Read the configured SSH wrapper path
Git::Config.instance.git_ssh #=> "/usr/bin/ssh-wrapper"
@return [String, nil] the configured SSH wrapper path
Source
# File lib/git/config.rb, line 85 def timeout @timeout || (ENV.fetch('GIT_TIMEOUT', nil) && ENV['GIT_TIMEOUT'].to_i) end
Returns the timeout for git operations
Uses an explicitly configured timeout first, then ‘GIT_TIMEOUT`.
@example Read the configured timeout
Git::Config.instance.timeout #=> 30
@return [Integer, nil] the timeout in seconds