bump-cask-pr: handle additional use cases
This commit is contained in:
parent
90451321e6
commit
504bdd2816
@ -87,6 +87,7 @@ module Cask
|
||||
:discontinued?,
|
||||
:livecheck,
|
||||
:livecheckable?,
|
||||
:on_system_blocks_exist?,
|
||||
*ORDINARY_ARTIFACT_CLASSES.map(&:dsl_key),
|
||||
*ACTIVATABLE_ARTIFACT_CLASSES.map(&:dsl_key),
|
||||
*ARTIFACT_BLOCK_CLASSES.flat_map { |klass| [klass.dsl_key, klass.uninstall_dsl_key] },
|
||||
|
||||
@ -78,14 +78,14 @@ module Homebrew
|
||||
odie "This cask's tap is not a Git repository!" unless cask.tap.git?
|
||||
|
||||
new_version = args.version
|
||||
new_version = :latest if ["latest", ":latest"].include?(new_version)
|
||||
new_version = :latest if ["latest", ":latest"].include? new_version
|
||||
new_version = Cask::DSL::Version.new(new_version) if new_version.present?
|
||||
new_base_url = args.url
|
||||
new_hash = args.sha256
|
||||
new_hash = :no_check if ["no_check", ":no_check"].include? new_hash
|
||||
|
||||
if new_version.nil? && new_base_url.nil? && new_hash.nil?
|
||||
raise UsageError, "No --version=/--url=/--sha256= argument specified!"
|
||||
raise UsageError, "No `--version=`, `--url=` or `--sha256=` argument specified!"
|
||||
end
|
||||
|
||||
old_version = cask.version
|
||||
@ -104,25 +104,14 @@ module Homebrew
|
||||
/version\s+#{old_version_regex}/m,
|
||||
"version #{new_version.latest? ? ":latest" : "\"#{new_version}\""}",
|
||||
]
|
||||
if new_version.latest? || new_hash == :no_check
|
||||
opoo "Ignoring specified `--sha256=` argument." if new_hash.is_a? String
|
||||
replacement_pairs << [/"#{old_hash}"/, ":no_check"] if old_hash != :no_check
|
||||
elsif old_hash != :no_check
|
||||
if new_hash.nil? || cask.languages.present?
|
||||
if new_hash.present? && cask.languages.present?
|
||||
opoo "Multiple hash replacements required; ignoring specified `--sha256=` argument."
|
||||
end
|
||||
|
||||
if new_base_url.present?
|
||||
m = /^ +url "(.+?)"\n/m.match(old_contents)
|
||||
odie "Could not find old URL in cask!" if m.nil?
|
||||
|
||||
old_base_url = m.captures.first
|
||||
|
||||
replacement_pairs << [
|
||||
/#{Regexp.escape(old_base_url)}/,
|
||||
new_base_url,
|
||||
]
|
||||
end
|
||||
|
||||
if new_version.present?
|
||||
if new_version.latest?
|
||||
opoo "Ignoring specified `--sha256=` argument." if new_hash.present?
|
||||
replacement_pairs << [old_hash, ":no_check"]
|
||||
elsif old_hash != :no_check && (new_hash.nil? || cask.languages.present?)
|
||||
tmp_contents = Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
||||
replacement_pairs.uniq.compact,
|
||||
read_only_run: true,
|
||||
@ -156,8 +145,24 @@ module Homebrew
|
||||
|
||||
Homebrew::SimulateSystem.clear
|
||||
end
|
||||
elsif new_hash.present?
|
||||
opoo "Cask contains multiple hashes; only updating hash for current arch." if cask.on_system_blocks_exist?
|
||||
replacement_pairs << [old_hash.to_s, new_hash]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if new_base_url.present?
|
||||
m = /^ +url "(.+?)"\n/m.match(old_contents)
|
||||
odie "Could not find old URL in cask!" if m.nil?
|
||||
|
||||
old_base_url = m.captures.first
|
||||
|
||||
replacement_pairs << [
|
||||
/#{Regexp.escape(old_base_url)}/,
|
||||
new_base_url,
|
||||
]
|
||||
end
|
||||
|
||||
Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
||||
replacement_pairs.uniq.compact,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user