Refactor tap and versions
This commit is contained in:
parent
e176159b23
commit
79fd5ee2b7
@ -32,7 +32,7 @@ module Cask
|
|||||||
tab.source = {
|
tab.source = {
|
||||||
"path" => cask.sourcefile_path.to_s,
|
"path" => cask.sourcefile_path.to_s,
|
||||||
"tap" => cask.tap&.name,
|
"tap" => cask.tap&.name,
|
||||||
"tap_git_head" => (cask.tap&.installed? ? cask.tap.git_head : nil),
|
"tap_git_head" => tap_git_head(cask),
|
||||||
"version" => cask.version.to_s,
|
"version" => cask.version.to_s,
|
||||||
}
|
}
|
||||||
tab.uninstall_artifacts = cask.artifacts_list(uninstall_only: true)
|
tab.uninstall_artifacts = cask.artifacts_list(uninstall_only: true)
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class AbstractTab
|
|||||||
"arch" => Hardware::CPU.arch,
|
"arch" => Hardware::CPU.arch,
|
||||||
"source" => {
|
"source" => {
|
||||||
"tap" => formula_or_cask.tap&.name,
|
"tap" => formula_or_cask.tap&.name,
|
||||||
"tap_git_head" => (formula_or_cask.tap&.installed? ? formula_or_cask.tap.git_head : nil),
|
"tap_git_head" => tap_git_head(formula_or_cask),
|
||||||
},
|
},
|
||||||
"built_on" => DevelopmentTools.build_system_info,
|
"built_on" => DevelopmentTools.build_system_info,
|
||||||
}
|
}
|
||||||
@ -93,6 +93,12 @@ class AbstractTab
|
|||||||
new(attributes)
|
new(attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.tap_git_head(formula_or_cask)
|
||||||
|
return unless formula_or_cask.tap&.installed?
|
||||||
|
|
||||||
|
formula_or_cask.tap.git_head
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
attributes.each { |key, value| instance_variable_set(:"@#{key}", value) }
|
attributes.each { |key, value| instance_variable_set(:"@#{key}", value) }
|
||||||
end
|
end
|
||||||
@ -176,13 +182,7 @@ class Tab < AbstractTab
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if tab.source["versions"].nil?
|
tab.source["versions"] ||= empty_source_versions
|
||||||
tab.source["versions"] = {
|
|
||||||
"stable" => nil,
|
|
||||||
"head" => nil,
|
|
||||||
"version_scheme" => 0,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# Tabs created with Homebrew 1.5.13 through 4.0.17 inclusive created empty string versions in some cases.
|
# Tabs created with Homebrew 1.5.13 through 4.0.17 inclusive created empty string versions in some cases.
|
||||||
["stable", "head"].each do |spec|
|
["stable", "head"].each do |spec|
|
||||||
@ -255,7 +255,7 @@ class Tab < AbstractTab
|
|||||||
tab.source = {
|
tab.source = {
|
||||||
"path" => formula.specified_path.to_s,
|
"path" => formula.specified_path.to_s,
|
||||||
"tap" => formula.tap&.name,
|
"tap" => formula.tap&.name,
|
||||||
"tap_git_head" => (formula.tap&.installed? ? formula.tap.git_head : nil),
|
"tap_git_head" => tap_git_head(formula),
|
||||||
"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,
|
||||||
@ -280,14 +280,19 @@ class Tab < AbstractTab
|
|||||||
tab.compiler = DevelopmentTools.default_compiler
|
tab.compiler = DevelopmentTools.default_compiler
|
||||||
tab.aliases = []
|
tab.aliases = []
|
||||||
tab.source["spec"] = "stable"
|
tab.source["spec"] = "stable"
|
||||||
tab.source["versions"] = {
|
tab.source["versions"] = empty_source_versions
|
||||||
|
|
||||||
|
tab
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.empty_source_versions
|
||||||
|
{
|
||||||
"stable" => nil,
|
"stable" => nil,
|
||||||
"head" => nil,
|
"head" => nil,
|
||||||
"version_scheme" => 0,
|
"version_scheme" => 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
tab
|
|
||||||
end
|
end
|
||||||
|
private_class_method :empty_source_versions
|
||||||
|
|
||||||
def self.runtime_deps_hash(formula, deps)
|
def self.runtime_deps_hash(formula, deps)
|
||||||
deps.map do |dep|
|
deps.map do |dep|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user