Class: Git::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/git/config.rb

Overview

The global configuration for this gem

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



44
45
46
47
48
# File 'lib/git/config.rb', line 44

def initialize
  @binary_path = nil
  @git_ssh = nil
  @timeout = nil
end

Instance Attribute Details

#binary_pathString

Returns the git executable path

Uses an explicitly configured path first, then GIT_PATH, then git.

Examples:

Read the default executable

Git::Config.instance.binary_path #=> "git"

Returns:

  • (String)

    the git executable path



59
60
61
# 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

#git_sshString?

Returns the SSH wrapper path used by git operations

Uses an explicitly configured wrapper path first, then GIT_SSH.

Examples:

Read the configured SSH wrapper path

Git::Config.instance.git_ssh #=> "/usr/bin/ssh-wrapper"

Returns:

  • (String, nil)

    the configured SSH wrapper path



72
73
74
# File 'lib/git/config.rb', line 72

def git_ssh
  @git_ssh || ENV.fetch('GIT_SSH', nil)
end

#timeoutInteger?

Returns the timeout for git operations

Uses an explicitly configured timeout first, then GIT_TIMEOUT.

Examples:

Read the configured timeout

Git::Config.instance.timeout #=> 30

Returns:

  • (Integer, nil)

    the timeout in seconds



85
86
87
# File 'lib/git/config.rb', line 85

def timeout
  @timeout || (ENV.fetch('GIT_TIMEOUT', nil) && ENV['GIT_TIMEOUT'].to_i)
end

Class Method Details

.instanceGit::Config

Returns the process-wide singleton Git::Config instance

All calls to Git.configure, Git.config, and the ExecutionContext classes resolve global configuration through this method.

Examples:

Read the configured binary path

Git::Config.instance.binary_path  #=> "git"

Mutate the singleton (same as Git.configure { |c| ... })

Git::Config.instance.binary_path = '/usr/local/bin/git'

Returns:



22
23
24
# File 'lib/git/config.rb', line 22

def self.instance
  @instance ||= new
end