Skip to content

Commit b9cd477

Browse files
committed
If any file changed only parse all files if force-update is true
Commit 13e9a44 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. After this commit, if `--force-update` is false, only files newer than the previous parse will be parsed.
1 parent 06137bd commit b9cd477

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/rdoc/rdoc.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,14 @@ def gather_files files
125125

126126
file_list = remove_unparseable(file_list)
127127

128+
result = []
128129
if file_list.count {|name, mtime|
130+
result << name if mtime || @options.force_update
129131
file_list[name] = @last_modified[name] unless mtime
130132
mtime
131133
} > 0
132134
@last_modified.replace file_list
133-
file_list.keys.sort
135+
result.sort
134136
else
135137
[]
136138
end

test/rdoc/test_rdoc_rdoc.rb

+11
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ def test_gather_files
8080
assert_equal [a, b], @rdoc.gather_files([b, a, b])
8181
end
8282

83+
def test_gather_files_with_no_force_update
84+
a = File.expand_path __FILE__
85+
b = File.expand_path '../test_rdoc_text.rb', __FILE__
86+
87+
assert_equal [a, b], @rdoc.gather_files([a, b])
88+
89+
@rdoc.last_modified[a] -= 10
90+
@rdoc.options.force_update = false
91+
assert_equal [a], @rdoc.gather_files([a, b])
92+
end
93+
8394
def test_handle_pipe
8495
$stdin = StringIO.new "hello"
8596

0 commit comments

Comments
 (0)