Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump-cask-pr: add arch-specific version support #15725

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Library/Homebrew/bump_version_parser.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# typed: strict
# frozen_string_literal: true

module Homebrew
# Class handling architecture-specific version information.
#
# @api private
class BumpVersionParser
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
end
end
20 changes: 11 additions & 9 deletions Library/Homebrew/cask/cask.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module Cask
class Cask
def appcast; end

def appdir; end

def artifacts; end

def auto_updates; end
Expand All @@ -14,32 +16,32 @@ module Cask

def container; end

def depends_on; end

def desc; end

def depends_on; end
def discontinued?; end

def homepage; end

def language; end

def languages; end

def livecheck; end

def livecheckable?; end

def name; end

def on_system_blocks_exist?; end

def sha256; end

def staged_path; end

def url; end

def version; end

def appdir; end

def discontinued?; end

def livecheck; end

def livecheckable?; end
end
end
Loading
Loading