mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

Move some stuff formerly in `Library/ENV` around: - Move `Library/ENV/$XCODE_VERSION` to `Library/Homebrew/env/super` as they are all superenv wrappers and all symlinks to the same version. We never needed the "separate shims for separate versions" functionality and it just adds confusion. - Move `Library/ENV/pkgconfig` to `Library/Homebrew/env/pkgconfig` to get more things under `Library/Homebrew` - Move `Library/ENV/scm` to `Library/scm` as these wrappers are not actually used by or related to superenv (or stdenv) in any way.
46 lines
1.1 KiB
Ruby
46 lines
1.1 KiB
Ruby
module Utils
|
|
def self.git_available?
|
|
return @git if instance_variable_defined?(:@git)
|
|
@git = quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
|
end
|
|
|
|
def self.git_path
|
|
return unless git_available?
|
|
@git_path ||= Utils.popen_read(
|
|
HOMEBREW_SHIMS_PATH/"scm/git", "--homebrew=print-path"
|
|
).chuzzle
|
|
end
|
|
|
|
def self.git_version
|
|
return unless git_available?
|
|
@git_version ||= Utils.popen_read(
|
|
HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
|
).chomp[/git version (\d+(?:\.\d+)*)/, 1]
|
|
end
|
|
|
|
def self.ensure_git_installed!
|
|
return if git_available?
|
|
|
|
# we cannot install brewed git if homebrew/core is unavailable.
|
|
unless CoreTap.instance.installed?
|
|
raise "Git is unavailable"
|
|
end
|
|
|
|
begin
|
|
oh1 "Installing git"
|
|
safe_system HOMEBREW_BREW_FILE, "install", "git"
|
|
rescue
|
|
raise "Git is unavailable"
|
|
end
|
|
|
|
clear_git_available_cache
|
|
raise "Git is unavailable" unless git_available?
|
|
end
|
|
|
|
def self.clear_git_available_cache
|
|
remove_instance_variable(:@git) if instance_variable_defined?(:@git)
|
|
@git_path = nil
|
|
@git_version = nil
|
|
end
|
|
end
|