From eed0f6bcdd006a6e8f526d10b08330609b425860 Mon Sep 17 00:00:00 2001 From: Alexander Kireev Date: Fri, 3 Jul 2026 06:39:21 +0700 Subject: [PATCH] FileList#<< should skip excluded entries include() has always filtered out anything matching an exclude pattern, but << just appended straight to @items with no check. So exclude("abc.c") followed by << "abc.c" left abc.c in the list, while the equivalent include("abc.c") correctly dropped it. Added a test for it. --- lib/rake/file_list.rb | 3 ++- test/test_rake_file_list.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index 76078d269..757f30a5f 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -202,7 +202,8 @@ def *(other) def <<(obj) resolve - @items << Rake.from_pathname(obj) + fn = Rake.from_pathname(obj) + @items << fn unless excluded_from_list?(fn) self end diff --git a/test/test_rake_file_list.rb b/test/test_rake_file_list.rb index 45f695d4f..3ea0cac58 100644 --- a/test/test_rake_file_list.rb +++ b/test/test_rake_file_list.rb @@ -100,6 +100,16 @@ def test_append_pathname assert_equal ["a.rb"], fl end + def test_append_respects_exclude + fl = FileList.new + fl.exclude "abc.c" + fl << "abc.c" + assert_equal [], fl + + fl << "xyz.c" + assert_equal ["xyz.c"], fl + end + def test_add_many fl = FileList.new fl.include %w(a d c)