Skip to content

Commit

Permalink
If any file changed only parse all files if force-update is true
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
p8 committed Jan 30, 2024
1 parent 06137bd commit b9cd477
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rdoc/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions test/rdoc/test_rdoc_rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit b9cd477

Please sign in to comment.