Module: Homebrew::Settings Private

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

Class Method Details

.delete(setting, repo: HOMEBREW_REPOSITORY) ⇒ Object

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.



29
30
31
32
33
34
35
# File 'settings.rb', line 29

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

  return if read(setting, repo:).nil?

  Kernel.system("git", "-C", repo.to_s, "config", "--unset-all", "homebrew.#{setting}", exception: true)
end

.read(setting, repo: HOMEBREW_REPOSITORY) ⇒ Object

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.



9
10
11
12
13
14
15
16
17
# File 'settings.rb', line 9

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

  value = Utils.popen_read("git", "-C", repo.to_s, "config", "--get", "homebrew.#{setting}").chomp

  return if value.strip.empty?

  value
end

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

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.



19
20
21
22
23
24
25
26
27
# File 'settings.rb', line 19

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

  value = value.to_s

  return if read(setting, repo:) == value

  Kernel.system("git", "-C", repo.to_s, "config", "--replace-all", "homebrew.#{setting}", value, exception: true)
end