From e464903e3eb871a1006b5d0d8cc2a36368280ad4 Mon Sep 17 00:00:00 2001 From: Daniel Azuma Date: Mon, 13 May 2024 18:41:30 -0700 Subject: [PATCH] chore: Fix for batch-reviewer (#25906) --- .toys/batch-review/.preload/batch_reviewer.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.toys/batch-review/.preload/batch_reviewer.rb b/.toys/batch-review/.preload/batch_reviewer.rb index 798c25ecc471..f4dfc8261372 100644 --- a/.toys/batch-review/.preload/batch_reviewer.rb +++ b/.toys/batch-review/.preload/batch_reviewer.rb @@ -159,7 +159,7 @@ def parse_diff_expectations expr raise "Unknown prefix code #{prefix.inspect} when parsing expect-diffs" end end - {path_exprs: path_exprs, additions: additions, removals: removals, desc: desc} + {path_patterns: path_exprs, additions: additions, removals: removals, desc: desc} end def validate_config @@ -516,13 +516,16 @@ def expect_diffs path_patterns: nil, additions: nil, removals: nil, desc: nil @expected << Expectation.new(desc) do |file| (path_patterns.empty? || path_patterns.any? { |pattern| pattern === file.path }) && file.reduce_hunks(true) do |val, hunk| - line_without_mark = line[1..] - if line.start_with? "+" - additions.any? { |regex| regex.match? line_without_mark } - elsif line.start_with? "-" - removals.any? { |regex| regex.match? line_without_mark } - else - true + next false unless val + hunk.all? do |line| + line_without_mark = line[1..] + if line.start_with? "+" + additions.any? { |regex| regex.match? line_without_mark } + elsif line.start_with? "-" + removals.any? { |regex| regex.match? line_without_mark } + else + true + end end end end