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

dev-cmd/bump: Point out if formulae should be kept in sync with others #16515

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions Library/Homebrew/dev-cmd/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,14 @@
Latest livecheck version: #{new_versions}
Latest Repology version: #{repology_latest}
EOS
if formula_or_cask.is_a?(Formula)
require "formula_auditor"

Check warning on line 464 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L463-L464

Added lines #L463 - L464 were not covered by tests
auditor = FormulaAuditor.new(formula_or_cask)
puts <<~EOS if auditor.synced_with_other_formulae?
Version syncing: #{title_name} version should be kept in sync with
#{synced_with(auditor, formula_or_cask, new_version.general).join(", ")}.
EOS
end
puts <<~EOS unless args.no_pull_requests?
Open pull requests: #{open_pull_requests || "none"}
Closed pull requests: #{closed_pull_requests || "none"}
Expand Down Expand Up @@ -497,4 +505,28 @@

system HOMEBREW_BREW_FILE, *bump_cask_pr_args
end

sig {
params(
auditor: FormulaAuditor,
formula: Formula,

Check warning on line 512 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L512

Added line #L512 was not covered by tests
new_version: T.nilable(T.any(Version, Cask::DSL::Version)),
).returns(T::Array[String])
}
def synced_with(auditor, formula, new_version)

Check warning on line 516 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L516

Added line #L516 was not covered by tests
synced_with = []

auditor.synced_versions_formulae_json.each do |synced_formulae|
next unless synced_formulae.include?(formula.name)

synced_formulae.each do |synced_formula|
synced_formula = Formulary.factory(synced_formula)

Check warning on line 523 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L523

Added line #L523 was not covered by tests
next if synced_formula == formula.name

Check warning on line 525 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L525

Added line #L525 was not covered by tests
synced_with << synced_formula.name if synced_formula.version != new_version
end
end

Check warning on line 529 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L528-L529

Added lines #L528 - L529 were not covered by tests
synced_with
end
end
22 changes: 15 additions & 7 deletions Library/Homebrew/formula_auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,28 @@
@aliases ||= Formula.aliases + Formula.tap_aliases
end

SYNCED_VERSIONS_FORMULAE_FILE = "synced_versions_formulae.json"
def synced_versions_formulae_json
@synced_versions_formulae_json ||= JSON.parse(File.read("#{formula.tap.path}/synced_versions_formulae.json"))

Check warning on line 145 in Library/Homebrew/formula_auditor.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_auditor.rb#L145

Added line #L145 was not covered by tests
end

def synced_with_other_formulae?
return false unless formula.tap

synced_versions_formulae_file = "#{formula.tap.path}/synced_versions_formulae.json"

Check warning on line 151 in Library/Homebrew/formula_auditor.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_auditor.rb#L151

Added line #L151 was not covered by tests
return false unless File.exist?(synced_versions_formulae_file)

synced_versions_formulae_json.any? { |synced_version_formulae| synced_version_formulae.include?(formula.name) }

Check warning on line 154 in Library/Homebrew/formula_auditor.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_auditor.rb#L154

Added line #L154 was not covered by tests
end

def audit_synced_versions_formulae
return unless formula.tap

synced_versions_formulae_file = formula.tap.path/SYNCED_VERSIONS_FORMULAE_FILE
return unless synced_versions_formulae_file.file?
return unless synced_with_other_formulae?

name = formula.name
version = formula.version

synced_versions_formulae = JSON.parse(synced_versions_formulae_file.read)
synced_versions_formulae.each do |synced_version_formulae|
next unless synced_version_formulae.include? name
synced_versions_formulae_json.each do |synced_version_formulae|

Check warning on line 164 in Library/Homebrew/formula_auditor.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_auditor.rb#L164

Added line #L164 was not covered by tests
next unless synced_version_formulae.include?(name)

synced_version_formulae.each do |synced_formula|
next if synced_formula == name
Expand Down