livecheck: convert head-only strings to Versions
`brew livecheck` currently gives a Sorbet type error when run on a HEAD-only formula: `Parameter 'version': Expected type Version, got type String with value "c06c10d"`. This happens because the `current` and `latest` values are strings but `LivecheckVersion#create` expects a `Version` object. This addresses the issue by creating a `Version` object from the related commit strings. This ensures that the type of these variables is more uniform, which makes them easier to reason about.
This commit is contained in:
parent
31f4570cc2
commit
f23d0ce373
@ -270,7 +270,7 @@ module Homebrew
|
||||
# comparison.
|
||||
current = if formula
|
||||
if formula.head_only?
|
||||
formula.any_installed_version.version.commit
|
||||
Version.new(formula.any_installed_version.version.commit)
|
||||
else
|
||||
T.must(formula.stable).version
|
||||
end
|
||||
@ -279,10 +279,10 @@ module Homebrew
|
||||
end
|
||||
|
||||
current_str = current.to_s
|
||||
current = LivecheckVersion.create(formula_or_cask, current) unless formula&.head_only?
|
||||
current = LivecheckVersion.create(formula_or_cask, current)
|
||||
|
||||
latest = if formula&.head_only?
|
||||
T.must(formula.head).downloader.fetch_last_commit
|
||||
Version.new(T.must(formula.head).downloader.fetch_last_commit)
|
||||
else
|
||||
version_info = latest_version(
|
||||
formula_or_cask,
|
||||
@ -345,7 +345,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
latest_str = latest.to_s
|
||||
latest = LivecheckVersion.create(formula_or_cask, latest) unless formula&.head_only?
|
||||
latest = LivecheckVersion.create(formula_or_cask, latest)
|
||||
|
||||
is_outdated = if formula&.head_only?
|
||||
# A HEAD-only formula is considered outdated if the latest upstream
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user