Skip to content

Commit 35e180b

Browse files
hsbtclaude
andcommitted
Apply exclude patterns when shoveling into FileList
FileList#<< pushed the new entry after resolve and never ran it through excluded_from_list?, so a name added after #exclude (or one matching a default ignore pattern such as core or *.bak) leaked into the list while #include correctly dropped it. Filter the appended name so #<< shares the same exclusion semantics as #include, which also means default ignore patterns now apply to shoveled entries. #637 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f7e9df5 commit 35e180b

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

lib/rake/file_list.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ def *(other)
202202

203203
def <<(obj)
204204
resolve
205-
@items << Rake.from_pathname(obj)
205+
fn = Rake.from_pathname(obj)
206+
@items << fn unless excluded_from_list?(fn)
206207
self
207208
end
208209

test/test_rake_file_list.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ def test_append_pathname
100100
assert_equal ["a.rb"], fl
101101
end
102102

103+
def test_append_respects_exclude
104+
fl = FileList.new
105+
fl.exclude("abc.c")
106+
fl << "abc.c"
107+
assert_equal [], fl.to_a
108+
end
109+
110+
def test_append_respects_default_ignore_patterns
111+
fl = FileList.new
112+
fl << "core"
113+
fl << "x.bak"
114+
fl << "keep.rb"
115+
assert_equal ["keep.rb"], fl.to_a
116+
end
117+
103118
def test_add_many
104119
fl = FileList.new
105120
fl.include %w(a d c)

0 commit comments

Comments
 (0)