Module: Homebrew::Settings Private

Extended by:
T::Sig
Includes:
SystemCommand::Mixin
Defined in:
settings.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper functions for reading and writing settings.

Class Method Summary collapse

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Class Method Details

.delete(setting, repo: HOMEBREW_REPOSITORY) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



35
36
37
38
39
40
41
42
# File 'settings.rb', line 35

def delete(setting, repo: HOMEBREW_REPOSITORY)
  return unless (repo/".git/config").exist?
  return if read(setting, repo: repo).blank?

  repo.cd do
    system_command! "git", args: ["config", "--unset-all", "homebrew.#{setting}"]
  end
end

.read(setting, repo: HOMEBREW_REPOSITORY) ⇒ String?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



17
18
19
20
21
22
23
# File 'settings.rb', line 17

def read(setting, repo: HOMEBREW_REPOSITORY)
  return unless (repo/".git/config").exist?

  repo.cd do
    Utils.popen_read("git", "config", "--get", "homebrew.#{setting}").chomp.presence
  end
end

.write(setting, value, repo: HOMEBREW_REPOSITORY) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



26
27
28
29
30
31
32
# File 'settings.rb', line 26

def write(setting, value, repo: HOMEBREW_REPOSITORY)
  return unless (repo/".git/config").exist?

  repo.cd do
    system_command! "git", args: ["config", "--replace-all", "homebrew.#{setting}", value.to_s]
  end
end