Skip to content

Commit

Permalink
chore: Fix for batch-reviewer (#25906)
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuma authored May 14, 2024
1 parent 776873e commit e464903
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .toys/batch-review/.preload/batch_reviewer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e464903

Please sign in to comment.