diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 742f1e6857..fb60951c01 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -60,7 +60,8 @@ module Hbc return if @cask.sourcefile_path.nil? tap = @cask.tap - return if tap.nil? || tap.user != "caskroom" + return if tap.nil? + return unless ["Homebrew", "caskroom"].include?(tap.user) return unless cask.artifacts.any? { |k| k.is_a?(Hbc::Artifact::Pkg) && k.stanza_options.key?(:allow_untrusted) } add_warning "allow_untrusted is not permitted in official Homebrew-Cask taps" diff --git a/Library/Homebrew/cask/lib/hbc/cli/search.rb b/Library/Homebrew/cask/lib/hbc/cli/search.rb index 480d7b5e54..429f9d5309 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/search.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/search.rb @@ -21,7 +21,7 @@ module Hbc def self.search_remote(query) matches = begin GitHub.search_code( - user: "caskroom", + user: ["Homebrew", "caskroom"], path: "Casks", filename: query, extension: "rb", diff --git a/Library/Homebrew/cask/lib/hbc/version.rb b/Library/Homebrew/cask/lib/hbc/version.rb index c7ce8e2d8c..9330999309 100644 --- a/Library/Homebrew/cask/lib/hbc/version.rb +++ b/Library/Homebrew/cask/lib/hbc/version.rb @@ -3,7 +3,7 @@ module Hbc @full_version ||= begin <<~EOS Homebrew-Cask #{HOMEBREW_VERSION} - caskroom/homebrew-cask #{Hbc.default_tap.version_string} + #{Hbc.default_tap.full_name} #{Hbc.default_tap.version_string} EOS end end diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index b2d5dfdbed..ee08cd6e09 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -470,7 +470,7 @@ class Reporter next unless tabs.first.tap == tap # skip if installed formula is not from this tap. new_tap = Tap.fetch(new_tap_name) # For formulae migrated to cask: Auto-install cask or provide install instructions. - if new_tap_name == "caskroom/cask" + if ["homebrew/cask", "caskroom/cask"].include?(new_tap_name) if new_tap.installed? && (HOMEBREW_PREFIX/"Caskroom").directory? ohai "#{name} has been moved to Homebrew-Cask." ohai "brew unlink #{name}" diff --git a/Library/Homebrew/compat.rb b/Library/Homebrew/compat.rb index 1f8d3871b9..28630befb9 100644 --- a/Library/Homebrew/compat.rb +++ b/Library/Homebrew/compat.rb @@ -9,3 +9,4 @@ require "compat/extend/string" require "compat/gpg" require "compat/dependable" require "compat/os/mac" +require "compat/tap" diff --git a/Library/Homebrew/compat/tap.rb b/Library/Homebrew/compat/tap.rb new file mode 100644 index 0000000000..4230dcef7c --- /dev/null +++ b/Library/Homebrew/compat/tap.rb @@ -0,0 +1,38 @@ +class Tap + module Compat + def initialize(user, repo) + super + + return unless user == "caskroom" + + # TODO: Remove this check after migration. + return unless repo == "tap-migration-test" + + new_user = "Homebrew" + new_repo = (repo == "cask") ? repo : "cask-#{repo}" + + old_name = name + old_path = path + old_remote = path.git_origin + + super(new_user, new_repo) + + return unless old_path.git? + + new_name = name + new_path = path + new_remote = default_remote + + ohai "Migrating tap #{old_name} to #{new_name}..." if $stdout.tty? + + puts "Moving #{old_path} to #{new_path}..." if $stdout.tty? + path.dirname.mkpath + FileUtils.mv old_path, new_path + + puts "Changing remote from #{old_remote} to #{new_remote}..." if $stdout.tty? + new_path.git_origin = new_remote + end + end + + prepend Compat +end diff --git a/Library/Homebrew/extend/git_repository.rb b/Library/Homebrew/extend/git_repository.rb index 6b89d175ca..2f9b8d7458 100644 --- a/Library/Homebrew/extend/git_repository.rb +++ b/Library/Homebrew/extend/git_repository.rb @@ -13,6 +13,13 @@ module GitRepositoryExtension end end + def git_origin=(origin) + return unless git? && Utils.git_available? + cd do + safe_system "git", "remote", "set-url", "origin", origin + end + end + def git_head return unless git? && Utils.git_available? cd do diff --git a/Library/Homebrew/missing_formula.rb b/Library/Homebrew/missing_formula.rb index 3b4682d668..9648f49600 100644 --- a/Library/Homebrew/missing_formula.rb +++ b/Library/Homebrew/missing_formula.rb @@ -101,7 +101,7 @@ module Homebrew EOS break if new_tap_name == CoreTap.instance.name - install_cmd = if new_tap_user == "caskroom" + install_cmd = if new_tap_user == "caskroom" || (new_tap_user == "homebrew" && new_tap_repo.start_with?("cask")) "cask install" else "install" diff --git a/Library/Homebrew/test/cask/cli/info_spec.rb b/Library/Homebrew/test/cask/cli/info_spec.rb index 803204171f..12e93709ff 100644 --- a/Library/Homebrew/test/cask/cli/info_spec.rb +++ b/Library/Homebrew/test/cask/cli/info_spec.rb @@ -12,7 +12,7 @@ describe Hbc::CLI::Info, :cask do local-caffeine: 1.2.3 http://example.com/local-caffeine Not installed - From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb + From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/local-caffeine.rb ==> Name None ==> Artifacts @@ -26,7 +26,7 @@ describe Hbc::CLI::Info, :cask do local-caffeine: 1.2.3 http://example.com/local-caffeine Not installed - From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb + From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/local-caffeine.rb ==> Name None ==> Artifacts @@ -34,7 +34,7 @@ describe Hbc::CLI::Info, :cask do local-transmission: 2.61 http://example.com/local-transmission Not installed - From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-transmission.rb + From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/local-transmission.rb ==> Name None ==> Artifacts @@ -56,7 +56,7 @@ describe Hbc::CLI::Info, :cask do with-caveats: 1.2.3 http://example.com/local-caffeine Not installed - From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-caveats.rb + From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/with-caveats.rb ==> Name None ==> Artifacts @@ -82,7 +82,7 @@ describe Hbc::CLI::Info, :cask do with-conditional-caveats: 1.2.3 http://example.com/local-caffeine Not installed - From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-conditional-caveats.rb + From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/with-conditional-caveats.rb ==> Name None ==> Artifacts @@ -97,7 +97,7 @@ describe Hbc::CLI::Info, :cask do with-languages: 1.2.3 http://example.com/local-caffeine Not installed - From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-languages.rb + From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/with-languages.rb ==> Name None ==> Languages @@ -114,7 +114,7 @@ describe Hbc::CLI::Info, :cask do without-languages: 1.2.3 http://example.com/local-caffeine Not installed - From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/without-languages.rb + From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/without-languages.rb ==> Name None ==> Artifacts diff --git a/Library/Homebrew/test/cask/cli/style_spec.rb b/Library/Homebrew/test/cask/cli/style_spec.rb index 6f486ea939..ae5e24d2ec 100644 --- a/Library/Homebrew/test/cask/cli/style_spec.rb +++ b/Library/Homebrew/test/cask/cli/style_spec.rb @@ -89,7 +89,7 @@ describe Hbc::CLI::Style, :cask do end end - it { is_expected.to contain_exactly(a_path_ending_with("/caskroom/homebrew-spec/Casks"), a_path_ending_with("/third-party/homebrew-tap/Casks")) } + it { is_expected.to contain_exactly(a_path_ending_with("/homebrew/homebrew-cask-spec/Casks"), a_path_ending_with("/third-party/homebrew-tap/Casks")) } end context "when at least one cask token is a path that exists" do diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb index e7a5e561fe..4a58fbf5a9 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb @@ -27,7 +27,7 @@ RSpec.shared_context "Homebrew-Cask" do [Hbc::Config.global.binarydir, Hbc.caskroom, Hbc.cache].each(&:mkpath) - Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap| + Hbc.default_tap = Tap.fetch("Homebrew", "cask-spec").tap do |tap| FileUtils.mkdir_p tap.path.dirname FileUtils.ln_sf TEST_FIXTURE_DIR.join("cask"), tap.path end @@ -42,7 +42,6 @@ RSpec.shared_context "Homebrew-Cask" do FileUtils.rm_rf HOMEBREW_CASK_DIRS.values FileUtils.rm_rf [Hbc::Config.global.binarydir, Hbc.caskroom, Hbc.cache] Hbc.default_tap.path.unlink - FileUtils.rm_rf Hbc.default_tap.path.parent third_party_tap.path.unlink FileUtils.rm_rf third_party_tap.path.parent end