From 289fb5b39330c6b20d84463a6ba58874c84040f1 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Thu, 11 May 2023 02:25:04 +0100 Subject: [PATCH] tab: fix typing of versions --- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/tab.rb | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index fea502e41e..490be08d4c 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1233,7 +1233,7 @@ on_request: installed_on_request?, options: options) tab.time = Time.now.to_i tab.aliases = formula.aliases tab.arch = Hardware::CPU.arch - tab.source["versions"]["stable"] = formula.stable.version.to_s + tab.source["versions"]["stable"] = formula.stable.version&.to_s tab.source["versions"]["version_scheme"] = formula.version_scheme tab.source["path"] = formula.specified_path.to_s tab.source["tap_git_head"] = formula.tap&.installed? ? formula.tap&.git_head : nil diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 3258c4e34c..7fbddefb65 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -45,8 +45,8 @@ class Tab "tap_git_head" => nil, # Filled in later if possible "spec" => formula.active_spec_sym.to_s, "versions" => { - "stable" => formula.stable&.version.to_s, - "head" => formula.head&.version.to_s, + "stable" => formula.stable&.version&.to_s, + "head" => formula.head&.version&.to_s, "version_scheme" => formula.version_scheme, }, }, @@ -108,6 +108,11 @@ class Tab } end + # Tabs created with Homebrew 1.5.13 through 4.0.17 inclusive created empty string versions in some cases. + ["stable", "head"].each do |spec| + attributes["source"]["versions"][spec] = attributes["source"]["versions"][spec].presence + end + new(attributes) end @@ -171,8 +176,8 @@ class Tab "tap" => formula.tap&.name, "spec" => formula.active_spec_sym.to_s, "versions" => { - "stable" => formula.stable&.version.to_s, - "head" => formula.head&.version.to_s, + "stable" => formula.stable&.version&.to_s, + "head" => formula.head&.version&.to_s, "version_scheme" => formula.version_scheme, }, }