2020-06-29 10:16:58 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-29 09:47:19 -05:00
|
|
|
require "cli/parser"
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
module_function
|
|
|
|
|
|
|
|
def bump_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
2020-07-28 08:42:24 -05:00
|
|
|
`bump` [<options>]
|
2020-07-02 17:06:39 +00:00
|
|
|
|
2020-07-28 09:30:19 -05:00
|
|
|
Display out-of-date brew formulae and the latest version available.
|
|
|
|
Also displays whether a pull request has been opened with the URL.
|
2020-06-29 09:47:19 -05:00
|
|
|
EOS
|
2020-07-28 08:42:24 -05:00
|
|
|
flag "--formula=",
|
|
|
|
description: "Return results for package by name."
|
2020-07-23 11:21:12 -05:00
|
|
|
flag "--limit=",
|
|
|
|
description: "Limit number of package results returned."
|
2020-07-06 03:32:18 +00:00
|
|
|
switch :verbose
|
|
|
|
switch :debug
|
2020-06-29 09:47:19 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def bump
|
|
|
|
bump_args.parse
|
2020-07-01 10:21:57 -05:00
|
|
|
|
2020-07-28 09:30:19 -05:00
|
|
|
requested_formula = Homebrew.args.formula
|
2020-07-28 09:43:20 -05:00
|
|
|
requested_formula&.downcase!
|
2020-07-28 09:30:19 -05:00
|
|
|
|
2020-07-31 10:52:37 -05:00
|
|
|
raise FormulaUnavailableError, requested_formula if requested_formula && !validate_formula(requested_formula)
|
2020-07-02 17:06:39 +00:00
|
|
|
|
2020-07-31 10:52:37 -05:00
|
|
|
repology_data = if requested_formula
|
2020-07-28 09:43:20 -05:00
|
|
|
Repology.single_package_query(requested_formula)
|
|
|
|
else
|
|
|
|
Repology.parse_api_response
|
|
|
|
end
|
2020-07-28 09:30:19 -05:00
|
|
|
|
2020-07-31 10:52:37 -05:00
|
|
|
validated_formulae = Repology.validate_and_format_packages(repology_data)
|
|
|
|
display(validated_formulae)
|
2020-07-02 17:06:39 +00:00
|
|
|
end
|
|
|
|
|
2020-07-31 10:52:37 -05:00
|
|
|
def validate_formula(formula_name)
|
2020-07-06 03:32:18 +00:00
|
|
|
Formula[formula_name]
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2020-07-31 10:52:37 -05:00
|
|
|
def up_to_date?(package)
|
|
|
|
package[:current_formula_version] == package[:repology_latest_version] &&
|
|
|
|
package[:current_formula_version] == package[:livecheck_latest_version]
|
|
|
|
end
|
|
|
|
|
|
|
|
def display(formulae)
|
2020-07-22 10:06:54 -05:00
|
|
|
puts
|
2020-07-31 10:52:37 -05:00
|
|
|
formulae.each do |formula, package_details|
|
|
|
|
title = (up_to_date?(package_details) ? formula + " is up to date!" : formula).to_s
|
|
|
|
ohai title
|
2020-07-29 13:26:10 +00:00
|
|
|
puts "Current formula version: #{package_details[:current_formula_version]}"
|
|
|
|
puts "Latest Repology version: #{package_details[:repology_latest_version]}"
|
2020-07-29 13:26:40 +00:00
|
|
|
puts "Latest livecheck version: #{package_details[:livecheck_latest_version] || "Not found"}"
|
2020-07-30 01:15:37 +00:00
|
|
|
puts "Open pull requests: #{package_details[:open_pull_requests] || "None"}"
|
2020-07-02 17:06:39 +00:00
|
|
|
end
|
2020-06-29 09:47:19 -05:00
|
|
|
end
|
|
|
|
end
|