Skip to content

Commit 45f089f

Browse files
committed
Ruby: skip non-existent files in overlay changes JSON
The previous implementation returned None if any of the paths in the changes JSON couldn't be canonicalized. This could happen for files that were deleted in the diff. Now, it just ignores paths for which canonicalize() fails.
1 parent 665df4b commit 45f089f

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

ruby/extractor/src/extractor.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -357,17 +357,15 @@ fn get_overlay_changed_files() -> Option<HashSet<PathBuf>> {
357357
// ...
358358
// ]
359359
// }
360-
json_value
361-
.get("changes")?
362-
.as_array()?
363-
.iter()
364-
.map(|change| {
365-
change
366-
.as_str()
367-
.map(|s| PathBuf::from(s).canonicalize().ok())
368-
.flatten()
369-
})
370-
.collect()
360+
Some(
361+
json_value
362+
.get("changes")?
363+
.as_array()?
364+
.iter()
365+
.filter_map(|change| change.as_str())
366+
.filter_map(|s| PathBuf::from(s).canonicalize().ok())
367+
.collect(),
368+
)
371369
}
372370

373371
fn scan_coding_comment(content: &[u8]) -> std::option::Option<Cow<str>> {

0 commit comments

Comments
 (0)