Merge pull request #15088 from reitermarkus/cask-commit-format
Make `bump-cask-pr` commit format more concise.
This commit is contained in:
commit
244359f314
@ -77,12 +77,28 @@ module Homebrew
|
|||||||
odie "This cask is not in a tap!" if cask.tap.blank?
|
odie "This cask is not in a tap!" if cask.tap.blank?
|
||||||
odie "This cask's tap is not a Git repository!" unless cask.tap.git?
|
odie "This cask's tap is not a Git repository!" unless cask.tap.git?
|
||||||
|
|
||||||
new_version = args.version
|
new_version = unless (new_version = args.version).nil?
|
||||||
new_version = :latest if ["latest", ":latest"].include? new_version
|
raise UsageError, "`--version` must not be empty." if new_version.blank?
|
||||||
new_version = Cask::DSL::Version.new(new_version) if new_version.present?
|
|
||||||
new_base_url = args.url
|
new_version = :latest if ["latest", ":latest"].include?(new_version)
|
||||||
new_hash = args.sha256
|
Cask::DSL::Version.new(new_version)
|
||||||
new_hash = :no_check if ["no_check", ":no_check"].include? new_hash
|
end
|
||||||
|
|
||||||
|
new_hash = unless (new_hash = args.sha265).nil?
|
||||||
|
raise UsageError, "`--sha256` must not be empty." if new_hash.blank?
|
||||||
|
|
||||||
|
["no_check", ":no_check"].include?(new_hash) ? :no_check : new_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
new_base_url = unless (new_base_url = args.url).nil?
|
||||||
|
raise UsageError, "`--url` must not be empty." if new_base_url.blank?
|
||||||
|
|
||||||
|
begin
|
||||||
|
URI(new_base_url)
|
||||||
|
rescue URI::InvalidURIError
|
||||||
|
raise UsageError, "`--url` is not valid."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if new_version.nil? && new_base_url.nil? && new_hash.nil?
|
if new_version.nil? && new_base_url.nil? && new_hash.nil?
|
||||||
raise UsageError, "No `--version`, `--url` or `--sha256` argument specified!"
|
raise UsageError, "No `--version`, `--url` or `--sha256` argument specified!"
|
||||||
@ -98,8 +114,18 @@ module Homebrew
|
|||||||
old_contents = File.read(cask.sourcefile_path)
|
old_contents = File.read(cask.sourcefile_path)
|
||||||
|
|
||||||
replacement_pairs = []
|
replacement_pairs = []
|
||||||
|
branch_name = "bump-#{cask.token}"
|
||||||
|
commit_message = nil
|
||||||
|
|
||||||
|
if new_version
|
||||||
|
branch_name += "-#{new_version.tr(",:", "-")}"
|
||||||
|
commit_message_version = if new_version.before_comma == old_version.before_comma
|
||||||
|
new_version
|
||||||
|
else
|
||||||
|
new_version.before_comma
|
||||||
|
end
|
||||||
|
commit_message ||= "#{cask.token} #{commit_message_version}"
|
||||||
|
|
||||||
if new_version.present?
|
|
||||||
old_version_regex = old_version.latest? ? ":latest" : "[\"']#{Regexp.escape(old_version.to_s)}[\"']"
|
old_version_regex = old_version.latest? ? ":latest" : "[\"']#{Regexp.escape(old_version.to_s)}[\"']"
|
||||||
|
|
||||||
replacement_pairs << [
|
replacement_pairs << [
|
||||||
@ -107,12 +133,12 @@ module Homebrew
|
|||||||
"version #{new_version.latest? ? ":latest" : "\"#{new_version}\""}",
|
"version #{new_version.latest? ? ":latest" : "\"#{new_version}\""}",
|
||||||
]
|
]
|
||||||
if new_version.latest? || new_hash == :no_check
|
if new_version.latest? || new_hash == :no_check
|
||||||
opoo "Ignoring specified `--sha256=` argument." if new_hash.is_a? String
|
opoo "Ignoring specified `--sha256=` argument." if new_hash.is_a?(String)
|
||||||
replacement_pairs << [/"#{old_hash}"/, ":no_check"] if old_hash != :no_check
|
replacement_pairs << [/"#{old_hash}"/, ":no_check"] if old_hash != :no_check
|
||||||
elsif old_hash != :no_check
|
elsif old_hash != :no_check
|
||||||
if new_hash.nil? || cask.languages.present?
|
if new_hash.nil? || cask.languages.present?
|
||||||
if new_hash.present? && cask.languages.present?
|
if new_hash && cask.languages.present?
|
||||||
opoo "Multiple hash replacements required; ignoring specified `--sha256=` argument."
|
opoo "Multiple checksum replacements required; ignoring specified `--sha256` argument."
|
||||||
end
|
end
|
||||||
tmp_contents = Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
tmp_contents = Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
||||||
replacement_pairs.uniq.compact,
|
replacement_pairs.uniq.compact,
|
||||||
@ -147,14 +173,16 @@ module Homebrew
|
|||||||
ensure
|
ensure
|
||||||
Homebrew::SimulateSystem.clear
|
Homebrew::SimulateSystem.clear
|
||||||
end
|
end
|
||||||
elsif new_hash.present?
|
elsif new_hash
|
||||||
opoo "Cask contains multiple hashes; only updating hash for current arch." if cask.on_system_blocks_exist?
|
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]
|
replacement_pairs << [old_hash.to_s, new_hash]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if new_base_url.present?
|
if new_base_url
|
||||||
|
commit_message ||= "#{cask.token}: update URL"
|
||||||
|
|
||||||
m = /^ +url "(.+?)"\n/m.match(old_contents)
|
m = /^ +url "(.+?)"\n/m.match(old_contents)
|
||||||
odie "Could not find old URL in cask!" if m.nil?
|
odie "Could not find old URL in cask!" if m.nil?
|
||||||
|
|
||||||
@ -166,6 +194,8 @@ module Homebrew
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
commit_message ||= "#{cask.token}: update checksum" if new_hash
|
||||||
|
|
||||||
Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
||||||
replacement_pairs.uniq.compact,
|
replacement_pairs.uniq.compact,
|
||||||
read_only_run: args.dry_run?,
|
read_only_run: args.dry_run?,
|
||||||
@ -174,16 +204,6 @@ module Homebrew
|
|||||||
run_cask_audit(cask, old_contents, args: args)
|
run_cask_audit(cask, old_contents, args: args)
|
||||||
run_cask_style(cask, old_contents, args: args)
|
run_cask_style(cask, old_contents, args: args)
|
||||||
|
|
||||||
branch_name = "bump-#{cask.token}"
|
|
||||||
commit_message = "Update #{cask.token}"
|
|
||||||
if new_version.present?
|
|
||||||
if new_version.before_comma != old_version.before_comma
|
|
||||||
new_version = new_version.before_comma
|
|
||||||
old_version = old_version.before_comma
|
|
||||||
end
|
|
||||||
branch_name += "-#{new_version.tr(",:", "-")}"
|
|
||||||
commit_message += " from #{old_version} to #{new_version}"
|
|
||||||
end
|
|
||||||
pr_info = {
|
pr_info = {
|
||||||
sourcefile_path: cask.sourcefile_path,
|
sourcefile_path: cask.sourcefile_path,
|
||||||
old_contents: old_contents,
|
old_contents: old_contents,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user