
Currently `brew bump` will output `unable to get versions` for the livecheck (or Repology) version if it's lower than the current package version. This makes it impossible to distinguish between a failing livecheck and one where the livecheck version is lower. We can detect when the package version is newer than the upstream version but `bump` doesn't do anything to handle the situation. This addresses the issue by updating `bump` to display the lower upstream version and flag the current version with a trailing "(newer than upstream)" parenthetical to make the situation apparent (and so we can easily search for this text in the output).
62 lines
2.0 KiB
Ruby
62 lines
2.0 KiB
Ruby
# typed: strict
|
|
# frozen_string_literal: true
|
|
|
|
module Homebrew
|
|
# Class handling architecture-specific version information.
|
|
class BumpVersionParser
|
|
VERSION_SYMBOLS = [:general, :arm, :intel].freeze
|
|
|
|
sig { returns(T.nilable(T.any(Version, Cask::DSL::Version))) }
|
|
attr_reader :arm, :general, :intel
|
|
|
|
sig {
|
|
params(general: T.nilable(T.any(Version, String)),
|
|
arm: T.nilable(T.any(Version, String)),
|
|
intel: T.nilable(T.any(Version, String))).void
|
|
}
|
|
def initialize(general: nil, arm: nil, intel: nil)
|
|
@general = T.let(parse_version(general), T.nilable(T.any(Version, Cask::DSL::Version))) if general.present?
|
|
@arm = T.let(parse_version(arm), T.nilable(T.any(Version, Cask::DSL::Version))) if arm.present?
|
|
@intel = T.let(parse_version(intel), T.nilable(T.any(Version, Cask::DSL::Version))) if intel.present?
|
|
|
|
return if @general.present?
|
|
raise UsageError, "`--version` must not be empty." if arm.blank? && intel.blank?
|
|
raise UsageError, "`--version-arm` must not be empty." if arm.blank?
|
|
raise UsageError, "`--version-intel` must not be empty." if intel.blank?
|
|
end
|
|
|
|
sig {
|
|
params(version: T.any(Version, String))
|
|
.returns(T.nilable(T.any(Version, Cask::DSL::Version)))
|
|
}
|
|
def parse_version(version)
|
|
if version.is_a?(Version)
|
|
version
|
|
elsif version.is_a?(String)
|
|
parse_cask_version(version)
|
|
end
|
|
end
|
|
|
|
sig { params(version: String).returns(T.nilable(Cask::DSL::Version)) }
|
|
def parse_cask_version(version)
|
|
if version == "latest"
|
|
Cask::DSL::Version.new(:latest)
|
|
else
|
|
Cask::DSL::Version.new(version)
|
|
end
|
|
end
|
|
|
|
sig { returns(T::Boolean) }
|
|
def blank?
|
|
@general.blank? && @arm.blank? && @intel.blank?
|
|
end
|
|
|
|
sig { params(other: T.untyped).returns(T::Boolean) }
|
|
def ==(other)
|
|
return false unless other.is_a?(BumpVersionParser)
|
|
|
|
(general == other.general) && (arm == other.arm) && (intel == other.intel)
|
|
end
|
|
end
|
|
end
|