tab: fix typing of versions

This commit is contained in:
Bo Anderson 2023-05-11 02:25:04 +01:00
parent 5f2ccd22f2
commit 289fb5b393
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 10 additions and 5 deletions

View File

@ -1233,7 +1233,7 @@ on_request: installed_on_request?, options: options)
tab.time = Time.now.to_i tab.time = Time.now.to_i
tab.aliases = formula.aliases tab.aliases = formula.aliases
tab.arch = Hardware::CPU.arch 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["versions"]["version_scheme"] = formula.version_scheme
tab.source["path"] = formula.specified_path.to_s tab.source["path"] = formula.specified_path.to_s
tab.source["tap_git_head"] = formula.tap&.installed? ? formula.tap&.git_head : nil tab.source["tap_git_head"] = formula.tap&.installed? ? formula.tap&.git_head : nil

View File

@ -45,8 +45,8 @@ class Tab
"tap_git_head" => nil, # Filled in later if possible "tap_git_head" => nil, # Filled in later if possible
"spec" => formula.active_spec_sym.to_s, "spec" => formula.active_spec_sym.to_s,
"versions" => { "versions" => {
"stable" => formula.stable&.version.to_s, "stable" => formula.stable&.version&.to_s,
"head" => formula.head&.version.to_s, "head" => formula.head&.version&.to_s,
"version_scheme" => formula.version_scheme, "version_scheme" => formula.version_scheme,
}, },
}, },
@ -108,6 +108,11 @@ class Tab
} }
end 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) new(attributes)
end end
@ -171,8 +176,8 @@ class Tab
"tap" => formula.tap&.name, "tap" => formula.tap&.name,
"spec" => formula.active_spec_sym.to_s, "spec" => formula.active_spec_sym.to_s,
"versions" => { "versions" => {
"stable" => formula.stable&.version.to_s, "stable" => formula.stable&.version&.to_s,
"head" => formula.head&.version.to_s, "head" => formula.head&.version&.to_s,
"version_scheme" => formula.version_scheme, "version_scheme" => formula.version_scheme,
}, },
} }