From d0136b74cf4fba6afe13b40dfa3c597397649cc8 Mon Sep 17 00:00:00 2001 From: Petrik Date: Tue, 30 Jan 2024 21:55:04 +0100 Subject: [PATCH] If any file changed only parse all files if `force-update` is true Commit 13e9a44896323535329331ffbc6c11813da53161 enforced parsing all files if any file is newer than the previous parse, not only updated files. However, this did not take into account the `--force-update` option and would parse all files even if `--force-update` was false. --- lib/rdoc/rdoc.rb | 4 +++- test/rdoc/test_rdoc_rdoc.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 2da6d9b575..516731c874 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -125,12 +125,14 @@ def gather_files files file_list = remove_unparseable(file_list) + result = [] if file_list.count {|name, mtime| + result << name if mtime || @options.force_update file_list[name] = @last_modified[name] unless mtime mtime } > 0 @last_modified.replace file_list - file_list.keys.sort + result.sort else [] end diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 5168932430..ae4f8904c1 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -80,6 +80,17 @@ def test_gather_files assert_equal [a, b], @rdoc.gather_files([b, a, b]) end + def test_gather_files_with_no_force_update + a = File.expand_path __FILE__ + b = File.expand_path '../test_rdoc_text.rb', __FILE__ + + assert_equal [a, b], @rdoc.gather_files([a, b]) + + @rdoc.last_modified[a] -= 10 + @rdoc.options.force_update = false + assert_equal [a], @rdoc.gather_files([a, b]) + end + def test_handle_pipe $stdin = StringIO.new "hello"