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.



31
32
33
34
35
36
37
# File 'settings.rb', line 31

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

  return if read(setting, repo: 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.



11
12
13
14
15
16
17
18
19
# File 'settings.rb', line 11

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.



21
22
23
24
25
26
27
28
29
# File 'settings.rb', line 21

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

  value = value.to_s

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

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