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.
This commit is contained in:
Nick Rolfe
2025-06-23 13:39:31 +01:00
parent 665df4baef
commit 45f089fda0

View File

@@ -357,17 +357,15 @@ fn get_overlay_changed_files() -> Option<HashSet<PathBuf>> {
// ...
// ]
// }
json_value
.get("changes")?
.as_array()?
.iter()
.map(|change| {
change
.as_str()
.map(|s| PathBuf::from(s).canonicalize().ok())
.flatten()
})
.collect()
Some(
json_value
.get("changes")?
.as_array()?
.iter()
.filter_map(|change| change.as_str())
.filter_map(|s| PathBuf::from(s).canonicalize().ok())
.collect(),
)
}
fn scan_coding_comment(content: &[u8]) -> std::option::Option<Cow<str>> {