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.



33
34
35
36
37
38
39
# File 'settings.rb', line 33

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

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

  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.



13
14
15
16
17
18
19
20
21
# File 'settings.rb', line 13

def 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.



23
24
25
26
27
28
29
30
31
# File 'settings.rb', line 23

def 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