diff --git a/Library/Homebrew/extend/os/mac/system_config.rb b/Library/Homebrew/extend/os/mac/system_config.rb index 144eae1eb5..b15bdc5268 100644 --- a/Library/Homebrew/extend/os/mac/system_config.rb +++ b/Library/Homebrew/extend/os/mac/system_config.rb @@ -29,6 +29,11 @@ module SystemConfig @clt ||= MacOS::CLT.version if MacOS::CLT.installed? end + def core_tap_config(out = $stdout) + dump_tap_config(CoreTap.instance, out) + dump_tap_config(CoreCaskTap.instance, out) + end + def dump_verbose_config(out = $stdout) dump_generic_verbose_config(out) out.puts "macOS: #{MacOS.full_version}-#{kernel}" diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb index c40562b29e..067f7500ab 100644 --- a/Library/Homebrew/system_config.rb +++ b/Library/Homebrew/system_config.rb @@ -50,26 +50,6 @@ module SystemConfig homebrew_repo.origin_url || "(none)" end - sig { returns(String) } - def core_tap_head - CoreTap.instance.git_head || "(none)" - end - - sig { returns(String) } - def core_tap_last_commit - CoreTap.instance.git_last_commit || "never" - end - - sig { returns(String) } - def core_tap_branch - CoreTap.instance.git_branch || "(none)" - end - - sig { returns(String) } - def core_tap_origin - CoreTap.instance.remote - end - sig { returns(String) } def describe_clang return "N/A" if clang.null? @@ -128,19 +108,34 @@ module SystemConfig end end - def core_tap_config(out = $stdout) - if CoreTap.instance.installed? - out.puts "Core tap origin: #{core_tap_origin}" - out.puts "Core tap HEAD: #{core_tap_head}" - out.puts "Core tap last commit: #{core_tap_last_commit}" - out.puts "Core tap branch: #{core_tap_branch}" + def dump_tap_config(tap, out = $stdout) + case tap + when CoreTap + tap_name = "Core tap" + json_file_name = "formula.jws.json" + when CoreCaskTap + tap_name = "Core cask tap" + json_file_name = "cask.jws.json" + else + raise ArgumentError, "Unknown tap: #{tap}" end - if (formula_json = Homebrew::API::HOMEBREW_CACHE_API/"formula.jws.json") && formula_json.exist? - out.puts "Core tap JSON: #{formula_json.mtime.utc.strftime("%d %b %H:%M UTC")}" - elsif !CoreTap.instance.installed? - out.puts "Core tap: N/A" + if tap.installed? + out.puts "#{tap_name} origin: #{tap.remote}" + out.puts "#{tap_name} HEAD: #{tap.git_head || "(none)"}" + out.puts "#{tap_name} last commit: #{tap.git_last_commit || "never"}" + out.puts "#{tap_name} branch: #{tap.git_branch || "(none)"}" end + + if (json_file = Homebrew::API::HOMEBREW_CACHE_API/json_file_name) && json_file.exist? + out.puts "#{tap_name} JSON: #{json_file.mtime.utc.strftime("%d %b %H:%M UTC")}" + elsif !tap.installed? + out.puts "#{tap_name}: N/A" + end + end + + def core_tap_config(out = $stdout) + dump_tap_config(CoreTap.instance, out) end def homebrew_config(out = $stdout)