From c5132daf630f3854e0b0a115bfee820aba334a02 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Wed, 9 Mar 2016 17:55:35 +0800 Subject: [PATCH] introduce `Homebrew/core` tap as new default core tap. It will be auto installed whenever necessary. --- Library/Homebrew/tap.rb | 57 ++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index e3d5b1cce9..32ef0fb9e1 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -1,6 +1,4 @@ require "extend/string" -require "tap_migrations" -require "formula_renames" # a {Tap} is used to extend the formulae provided by Homebrew core. # Usually, it's synced with a remote git repository. And it's likely @@ -447,23 +445,35 @@ class Tap end end -# A specialized {Tap} class to mimic the core formula file system, which shares many -# similarities with normal {Tap}. -# TODO Separate core formulae with core codes. See discussion below for future plan: -# https://github.com/Homebrew/homebrew/pull/46735#discussion_r46820565 +# A specialized {Tap} class for the core formulae class CoreTap < Tap + if OS.mac? + OFFICIAL_REMOTE = "https://github.com/Homebrew/homebrew-core" + else + OFFICIAL_REMOTE = "https://github.com/Linuxbrew/homebrew-core" + end + # @private def initialize - @user = "Homebrew" - @repo = "homebrew" - @name = "Homebrew/homebrew" - @path = HOMEBREW_REPOSITORY + super "Homebrew", "core" end def self.instance @instance ||= CoreTap.new end + def self.ensure_installed!(options = {}) + return if instance.installed? + args = ["tap", instance.name] + args << "-q" if options.fetch(:quiet, true) + safe_system HOMEBREW_BREW_FILE, *args + end + + def install(options = {}) + options = { :clone_target => OFFICIAL_REMOTE }.merge(options) + super options + end + # @private def uninstall raise "Tap#uninstall is not available for CoreTap" @@ -484,14 +494,9 @@ class CoreTap < Tap false end - # @private - def command_files - [] - end - # @private def custom_remote? - remote != "https://github.com/#{user}/#{repo}.git" + remote != OFFICIAL_REMOTE end # @private @@ -501,22 +506,34 @@ class CoreTap < Tap # @private def formula_dir - @formula_dir ||= HOMEBREW_LIBRARY/"Formula" + @formula_dir ||= begin + self.class.ensure_installed! + super + end end # @private def alias_dir - @alias_dir ||= HOMEBREW_LIBRARY/"Aliases" + @alias_dir ||= begin + self.class.ensure_installed! + super + end end # @private def formula_renames - FORMULA_RENAMES + @formula_renames ||= begin + self.class.ensure_installed! + super + end end # @private def tap_migrations - TAP_MIGRATIONS + @tap_migrations ||= begin + self.class.ensure_installed! + super + end end # @private