Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_relative "test_formulae"
require_relative "tests/cleanup_after"
require_relative "tests/cleanup_before"
require_relative "tests/formulae_detect"
require_relative "tests/packages_detect"
require_relative "tests/formulae_dependents"
require_relative "tests/bottles_fetch"
require_relative "tests/formulae"
Expand Down Expand Up @@ -142,7 +142,7 @@ def build_tests(argument, tap:, git:, output_paths:, skip_setup:,
args.added_formulae.nil? &&
args.deleted_formulae.nil?
if no_formulae_flags && (no_only_args || args.only_formulae? || args.only_formulae_detect?)
tests[:formulae_detect] = Tests::FormulaeDetect.new(argument, tap:,
tests[:formulae_detect] = Tests::PackagesDetect.new(argument, tap:,
git:,
dry_run: args.dry_run?,
fail_fast: args.fail_fast?,
Expand Down
27 changes: 14 additions & 13 deletions lib/tests/formulae_detect.rb → lib/tests/packages_detect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module Homebrew
module Tests
class FormulaeDetect < Test
class PackagesDetect < Test
attr_reader :testing_formulae, :added_formulae, :deleted_formulae

def initialize(argument, tap:, git:, dry_run:, fail_fast:, verbose:)
Expand All @@ -16,7 +16,7 @@ def initialize(argument, tap:, git:, dry_run:, fail_fast:, verbose:)
end

def run!(args:)
detect_formulae!(args:)
detect_packages!(args:)

return unless ENV["GITHUB_ACTIONS"]

Expand All @@ -30,8 +30,8 @@ def run!(args:)

private

def detect_formulae!(args:)
test_header(:FormulaeDetect, method: :detect_formulae!)
def detect_packages!(args:)
test_header(:PackagesDetect, method: :detect_formulae!)

url = nil
origin_ref = "origin/master"
Expand Down Expand Up @@ -132,11 +132,11 @@ def detect_formulae!(args:)
if tap && diff_start_sha1 != diff_end_sha1
formula_path = tap.formula_dir.to_s
@added_formulae +=
diff_formulae(diff_start_sha1, diff_end_sha1, formula_path, "A")
diff_packages(diff_start_sha1, diff_end_sha1, formula_path, "A")
modified_formulae +=
diff_formulae(diff_start_sha1, diff_end_sha1, formula_path, "M")
diff_packages(diff_start_sha1, diff_end_sha1, formula_path, "M")
@deleted_formulae +=
diff_formulae(diff_start_sha1, diff_end_sha1, formula_path, "D")
diff_packages(diff_start_sha1, diff_end_sha1, formula_path, "D")
end

# If a formula is both added and deleted: it's actually modified.
Expand Down Expand Up @@ -221,19 +221,20 @@ def current_sha1
rev_parse("HEAD")
end

def diff_formulae(start_revision, end_revision, path, filter)
def diff_packages(start_revision, end_revision, path, filter)
return unless tap

Utils.safe_popen_read(
git, "-C", repository,
"diff-tree", "-r", "--name-only", "--diff-filter=#{filter}",
start_revision, end_revision, "--", path
).lines(chomp: true).filter_map do |file|
next unless tap.formula_file?(file)

file = Pathname.new(file)
tap.formula_file_to_name(file)
end
if tap.formula_file?(file)
tap.formula_file_to_name(file)
elsif tap.cask_file?(file)
file.basename(".rb").to_s
end
end.compact
end
end
end
Expand Down
Loading