Fix merge conflicts
This commit is contained in:
parent
15da87704c
commit
d7149d1f76
@ -2,12 +2,12 @@ inherit_from: ../.rubocop_rspec.yml
|
|||||||
|
|
||||||
AllCops:
|
AllCops:
|
||||||
Include:
|
Include:
|
||||||
- '**/*.rb'
|
- "**/*.rb"
|
||||||
- 'Library/Homebrew/.simplecov'
|
- "Library/Homebrew/.simplecov"
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'bin/*'
|
- "bin/*"
|
||||||
- '**/Casks/**/*'
|
- "**/Casks/**/*"
|
||||||
- '**/vendor/**/*'
|
- "**/vendor/**/*"
|
||||||
|
|
||||||
# messes up system formatting for formulae but good for Homebrew/brew
|
# messes up system formatting for formulae but good for Homebrew/brew
|
||||||
Layout/ArgumentAlignment:
|
Layout/ArgumentAlignment:
|
||||||
@ -16,7 +16,7 @@ Layout/ArgumentAlignment:
|
|||||||
# make rspec formatting more flexible
|
# make rspec formatting more flexible
|
||||||
Layout/MultilineMethodCallIndentation:
|
Layout/MultilineMethodCallIndentation:
|
||||||
Exclude:
|
Exclude:
|
||||||
- '**/*_spec.rb'
|
- "**/*_spec.rb"
|
||||||
|
|
||||||
# so many of these in formulae but none in here
|
# so many of these in formulae but none in here
|
||||||
Lint/AmbiguousRegexpLiteral:
|
Lint/AmbiguousRegexpLiteral:
|
||||||
@ -29,7 +29,7 @@ Lint/AssignmentInCondition:
|
|||||||
# `formula do` uses nested method definitions
|
# `formula do` uses nested method definitions
|
||||||
Lint/NestedMethodDefinition:
|
Lint/NestedMethodDefinition:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'test/**/*'
|
- "test/**/*"
|
||||||
|
|
||||||
# so many of these in formulae but none in here
|
# so many of these in formulae but none in here
|
||||||
Lint/ParenthesesAsGroupedExpression:
|
Lint/ParenthesesAsGroupedExpression:
|
||||||
@ -47,7 +47,7 @@ Metrics/BlockLength:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
Max: 1100
|
Max: 1100
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'test/formula_spec.rb'
|
- "test/formula_spec.rb"
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Max: 5
|
Max: 5
|
||||||
@ -70,7 +70,7 @@ Metrics/PerceivedComplexity:
|
|||||||
# we won't change backward compatible predicate names
|
# we won't change backward compatible predicate names
|
||||||
Naming/PredicateName:
|
Naming/PredicateName:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'compat/**/*'
|
- "compat/**/*"
|
||||||
# can't rename these
|
# can't rename these
|
||||||
AllowedMethods: is_32_bit?, is_64_bit?
|
AllowedMethods: is_32_bit?, is_64_bit?
|
||||||
|
|
||||||
@ -78,27 +78,27 @@ Naming/PredicateName:
|
|||||||
# TODO: try to remove some of these
|
# TODO: try to remove some of these
|
||||||
Naming/MethodParameterName:
|
Naming/MethodParameterName:
|
||||||
AllowedNames:
|
AllowedNames:
|
||||||
- '_'
|
- "_"
|
||||||
- 'a'
|
- "a"
|
||||||
- 'b'
|
- "b"
|
||||||
- 'cc'
|
- "cc"
|
||||||
- 'c1'
|
- "c1"
|
||||||
- 'c2'
|
- "c2"
|
||||||
- 'd'
|
- "d"
|
||||||
- 'e'
|
- "e"
|
||||||
- 'f'
|
- "f"
|
||||||
- 'ff'
|
- "ff"
|
||||||
- 'fn'
|
- "fn"
|
||||||
- 'id'
|
- "id"
|
||||||
- 'io'
|
- "io"
|
||||||
- 'o'
|
- "o"
|
||||||
- 'p'
|
- "p"
|
||||||
- 'pr'
|
- "pr"
|
||||||
- 'r'
|
- "r"
|
||||||
- 'rb'
|
- "rb"
|
||||||
- 's'
|
- "s"
|
||||||
- 'to'
|
- "to"
|
||||||
- 'v'
|
- "v"
|
||||||
|
|
||||||
# Avoid false positives on modifiers used on symbols of methods
|
# Avoid false positives on modifiers used on symbols of methods
|
||||||
# See https://github.com/rubocop-hq/rubocop/issues/5953
|
# See https://github.com/rubocop-hq/rubocop/issues/5953
|
||||||
@ -108,18 +108,18 @@ Style/AccessModifierDeclarations:
|
|||||||
# make rspec formatting more flexible
|
# make rspec formatting more flexible
|
||||||
Style/BlockDelimiters:
|
Style/BlockDelimiters:
|
||||||
Exclude:
|
Exclude:
|
||||||
- '**/*_spec.rb'
|
- "**/*_spec.rb"
|
||||||
- '**/shared_examples/**/*.rb'
|
- "**/shared_examples/**/*.rb"
|
||||||
|
|
||||||
# document our public APIs
|
# document our public APIs
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Include:
|
Include:
|
||||||
- 'Library/Homebrew/formula.rb'
|
- "Library/Homebrew/formula.rb"
|
||||||
Style/DocumentationMethod:
|
Style/DocumentationMethod:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Include:
|
Include:
|
||||||
- 'Library/Homebrew/formula.rb'
|
- "Library/Homebrew/formula.rb"
|
||||||
|
|
||||||
# don't want this for formulae but re-enabled for Library/Homebrew
|
# don't want this for formulae but re-enabled for Library/Homebrew
|
||||||
Style/FrozenStringLiteralComment:
|
Style/FrozenStringLiteralComment:
|
||||||
|
|||||||
@ -314,7 +314,7 @@ module Homebrew
|
|||||||
|
|
||||||
new_formula_version = formula_version(formula, requested_spec, new_contents)
|
new_formula_version = formula_version(formula, requested_spec, new_contents)
|
||||||
|
|
||||||
check_for_duplicate_pull_requests(formula, tap_full_name, new_formula_version.to_s)
|
GitHub.check_for_duplicate_pull_requests(formula, tap_full_name, new_formula_version.to_s, args)
|
||||||
|
|
||||||
if !new_mirrors && !formula_spec.mirrors.empty?
|
if !new_mirrors && !formula_spec.mirrors.empty?
|
||||||
if args.force?
|
if args.force?
|
||||||
@ -469,41 +469,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_pull_requests(query, tap_full_name, state: nil)
|
|
||||||
GitHub.issues_for_formula(query, tap_full_name: tap_full_name, state: state).select do |pr|
|
|
||||||
pr["html_url"].include?("/pull/") &&
|
|
||||||
/(^|\s)#{Regexp.quote(query)}(:|\s|$)/i =~ pr["title"]
|
|
||||||
end
|
|
||||||
rescue GitHub::RateLimitExceededError => e
|
|
||||||
opoo e.message
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_for_duplicate_pull_requests(formula, tap_full_name, version)
|
|
||||||
# check for open requests
|
|
||||||
pull_requests = fetch_pull_requests(formula.name, tap_full_name, state: "open")
|
|
||||||
|
|
||||||
# if we haven't already found open requests, try for an exact match across all requests
|
|
||||||
pull_requests = fetch_pull_requests("#{formula.name} #{version}", tap_full_name) if pull_requests.blank?
|
|
||||||
return if pull_requests.blank?
|
|
||||||
|
|
||||||
duplicates_message = <<~EOS
|
|
||||||
These pull requests may be duplicates:
|
|
||||||
#{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")}
|
|
||||||
EOS
|
|
||||||
error_message = "Duplicate PRs should not be opened. Use --force to override this error."
|
|
||||||
if args.force? && !args.quiet?
|
|
||||||
opoo duplicates_message
|
|
||||||
elsif !args.force? && args.quiet?
|
|
||||||
odie error_message
|
|
||||||
elsif !args.force?
|
|
||||||
odie <<~EOS
|
|
||||||
#{duplicates_message.chomp}
|
|
||||||
#{error_message}
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def alias_update_pair(formula, new_formula_version)
|
def alias_update_pair(formula, new_formula_version)
|
||||||
versioned_alias = formula.aliases.grep(/^.*@\d+(\.\d+)?$/).first
|
versioned_alias = formula.aliases.grep(/^.*@\d+(\.\d+)?$/).first
|
||||||
return if versioned_alias.nil?
|
return if versioned_alias.nil?
|
||||||
|
|||||||
@ -12,18 +12,94 @@ module Homebrew
|
|||||||
|
|
||||||
Display out-of-date brew formulae, the latest version available, and whether a pull request has been opened.
|
Display out-of-date brew formulae, the latest version available, and whether a pull request has been opened.
|
||||||
EOS
|
EOS
|
||||||
|
switch :verbose
|
||||||
|
switch :debug
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def bump
|
def bump
|
||||||
bump_args.parse
|
bump_args.parse
|
||||||
|
|
||||||
outdated_repology_packages = RepologyParser.parse_api_response
|
outdated_repology_packages = Repology.parse_api_response
|
||||||
outdated_packages = RepologyParser.validate_and_format_packages(outdated_repology_packages)
|
outdated_packages = validate_and_format_packages(outdated_repology_packages)
|
||||||
|
|
||||||
display(outdated_packages)
|
display(outdated_packages)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_and_format_packages(outdated_repology_packages)
|
||||||
|
ohai "Verifying outdated repology packages as Homebrew Formulae"
|
||||||
|
|
||||||
|
packages = {}
|
||||||
|
outdated_repology_packages.each do |_name, repositories|
|
||||||
|
# identify homebrew repo
|
||||||
|
repology_homebrew_repo = repositories.find do |repo|
|
||||||
|
repo["repo"] == "homebrew"
|
||||||
|
end
|
||||||
|
|
||||||
|
next if repology_homebrew_repo.empty?
|
||||||
|
|
||||||
|
latest_version = nil
|
||||||
|
|
||||||
|
# identify latest version amongst repology repos
|
||||||
|
repositories.each do |repo|
|
||||||
|
latest_version = repo["version"] if repo["status"] == "newest"
|
||||||
|
end
|
||||||
|
|
||||||
|
packages[repology_homebrew_repo["srcname"]] = format_package(repology_homebrew_repo["srcname"], latest_version)
|
||||||
|
end
|
||||||
|
packages
|
||||||
|
end
|
||||||
|
|
||||||
|
def format_package(package_name, latest_version)
|
||||||
|
formula = get_formula_details(package_name)
|
||||||
|
return if formula.nil?
|
||||||
|
|
||||||
|
tap_full_name = formula.tap&.full_name
|
||||||
|
current_version = current_formula_version(formula)
|
||||||
|
livecheck_response = livecheck_formula(package_name)
|
||||||
|
pull_requests = GitHub.check_for_duplicate_pull_requests(formula, tap_full_name, latest_version, args, true)
|
||||||
|
|
||||||
|
{
|
||||||
|
repology_latest_version: latest_version,
|
||||||
|
current_formula_version: current_version.to_s,
|
||||||
|
livecheck_latest_version: livecheck_response[:livecheck_version],
|
||||||
|
open_pull_requests: pull_requests,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_formula_details(formula_name)
|
||||||
|
Formula[formula_name]
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_formula_version(formula)
|
||||||
|
formula.version.to_s
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def livecheck_formula(formula)
|
||||||
|
ohai "Checking livecheck formula: #{formula}" if Homebrew.args.verbose?
|
||||||
|
|
||||||
|
response = Utils.popen_read(HOMEBREW_BREW_FILE, "livecheck", formula, "--quiet").chomp
|
||||||
|
|
||||||
|
parse_livecheck_response(response)
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_livecheck_response(response)
|
||||||
|
output = response.delete(" ").split(/:|==>/)
|
||||||
|
|
||||||
|
# eg: ["openclonk", "7.0", "8.1"]
|
||||||
|
package_name, brew_version, latest_version = output
|
||||||
|
|
||||||
|
{
|
||||||
|
name: package_name,
|
||||||
|
formula_version: brew_version,
|
||||||
|
livecheck_version: latest_version,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def display(outdated_packages)
|
def display(outdated_packages)
|
||||||
ohai "Outdated Formulae\n"
|
ohai "Outdated Formulae\n"
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ require "utils/github"
|
|||||||
require "utils/inreplace"
|
require "utils/inreplace"
|
||||||
require "utils/link"
|
require "utils/link"
|
||||||
require "utils/popen"
|
require "utils/popen"
|
||||||
|
require "utils/repology"
|
||||||
require "utils/svn"
|
require "utils/svn"
|
||||||
require "utils/tty"
|
require "utils/tty"
|
||||||
require "utils/repology"
|
require "utils/repology"
|
||||||
|
|||||||
@ -337,6 +337,43 @@ module GitHub
|
|||||||
prs.each { |i| puts "#{i["title"]} (#{i["html_url"]})" }
|
prs.each { |i| puts "#{i["title"]} (#{i["html_url"]})" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fetch_pull_requests(query, tap_full_name, state: nil)
|
||||||
|
issues_for_formula(query, tap_full_name: tap_full_name, state: state).select do |pr|
|
||||||
|
pr["html_url"].include?("/pull/") &&
|
||||||
|
/(^|\s)#{Regexp.quote(query)}(:|\s|$)/i =~ pr["title"]
|
||||||
|
end
|
||||||
|
rescue GitHub::RateLimitExceededError => e
|
||||||
|
opoo e.message
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_for_duplicate_pull_requests(formula, tap_full_name, version, args, fetch_pr = false)
|
||||||
|
# check for open requests
|
||||||
|
pull_requests = fetch_pull_requests(formula.name, tap_full_name, state: "open")
|
||||||
|
|
||||||
|
# if we haven't already found open requests, try for an exact match across all requests
|
||||||
|
pull_requests = fetch_pull_requests("#{formula.name} #{version}", tap_full_name) if pull_requests.blank?
|
||||||
|
return if pull_requests.blank?
|
||||||
|
|
||||||
|
return pull_requests.map { |pr| { title: pr["title"], url: pr["html_url"] } } if fetch_pr
|
||||||
|
|
||||||
|
duplicates_message = <<~EOS
|
||||||
|
These pull requests may be duplicates:
|
||||||
|
#{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")}
|
||||||
|
EOS
|
||||||
|
error_message = "Duplicate PRs should not be opened. Use --force to override this error."
|
||||||
|
if args.force? && !args.quiet?
|
||||||
|
opoo duplicates_message
|
||||||
|
elsif !args.force? && args.quiet?
|
||||||
|
odie error_message
|
||||||
|
elsif !args.force?
|
||||||
|
odie <<~EOS
|
||||||
|
#{duplicates_message.chomp}
|
||||||
|
#{error_message}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def create_fork(repo)
|
def create_fork(repo)
|
||||||
url = "#{API_URL}/repos/#{repo}/forks"
|
url = "#{API_URL}/repos/#{repo}/forks"
|
||||||
data = {}
|
data = {}
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/curl"
|
require "utils/curl"
|
||||||
require "utils/versions"
|
|
||||||
|
|
||||||
require "formula_info"
|
module Repology
|
||||||
|
|
||||||
module RepologyParser
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
MAX_PAGINATION = 15
|
MAX_PAGINATION = 15
|
||||||
@ -14,7 +11,6 @@ module RepologyParser
|
|||||||
last_package_in_response += "/" unless last_package_in_response.empty?
|
last_package_in_response += "/" unless last_package_in_response.empty?
|
||||||
|
|
||||||
url = "https://repology.org/api/v1/projects/#{last_package_in_response}?inrepo=homebrew&outdated=1"
|
url = "https://repology.org/api/v1/projects/#{last_package_in_response}?inrepo=homebrew&outdated=1"
|
||||||
ohai "Calling API #{url}" if Homebrew.args.verbose?
|
|
||||||
|
|
||||||
output, _errors, _status = curl_output(url.to_s)
|
output, _errors, _status = curl_output(url.to_s)
|
||||||
JSON.parse(output)
|
JSON.parse(output)
|
||||||
@ -29,7 +25,7 @@ module RepologyParser
|
|||||||
page_no = 1
|
page_no = 1
|
||||||
|
|
||||||
while response_size > 1 && page_no <= MAX_PAGINATION
|
while response_size > 1 && page_no <= MAX_PAGINATION
|
||||||
ohai "Paginating Repology api page: #{page_no}" if Homebrew.args.verbose?
|
ohai "Paginating Repology api page: #{page_no}" if Homebrew.args.debug?
|
||||||
|
|
||||||
last_package_in_response = outdated_packages.keys[last_package_index]
|
last_package_in_response = outdated_packages.keys[last_package_index]
|
||||||
response = query_api(last_package_in_response)
|
response = query_api(last_package_in_response)
|
||||||
@ -44,41 +40,4 @@ module RepologyParser
|
|||||||
|
|
||||||
outdated_packages
|
outdated_packages
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_and_format_packages(outdated_repology_packages)
|
|
||||||
ohai "Verifying outdated repology packages as Homebrew Formulae"
|
|
||||||
|
|
||||||
packages = {}
|
|
||||||
outdated_repology_packages.each do |_name, repositories|
|
|
||||||
# identify homebrew repo
|
|
||||||
repology_homebrew_repo = repositories.find do |repo|
|
|
||||||
repo["repo"] == "homebrew"
|
|
||||||
end
|
|
||||||
|
|
||||||
next if repology_homebrew_repo.empty?
|
|
||||||
|
|
||||||
latest_version = nil
|
|
||||||
|
|
||||||
# identify latest version amongst repology repos
|
|
||||||
repositories.each do |repo|
|
|
||||||
latest_version = repo["version"] if repo["status"] == "newest"
|
|
||||||
end
|
|
||||||
|
|
||||||
packages[repology_homebrew_repo["srcname"]] = format_package(repology_homebrew_repo["srcname"], latest_version)
|
|
||||||
end
|
|
||||||
packages
|
|
||||||
end
|
|
||||||
|
|
||||||
def format_package(package_name, latest_version)
|
|
||||||
current_version = Versions.current_formula_version(package_name)
|
|
||||||
livecheck_response = Versions.livecheck_formula(package_name)
|
|
||||||
pull_requests = Versions.check_for_duplicate_pull_requests(package_name, latest_version)
|
|
||||||
|
|
||||||
{
|
|
||||||
repology_latest_version: latest_version,
|
|
||||||
current_formula_version: current_version.to_s,
|
|
||||||
livecheck_latest_version: livecheck_response[:livecheck_version],
|
|
||||||
open_pull_requests: pull_requests,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user