processRenames method
From list of files, split renames and flatten into
two files to
NULfrom
.
includeRenameFrom
Whether or not to include the
from
renamed file, which is no longer on disk
Implementation
List<String> processRenames(
List<String> filePaths, {
bool includeRenameFrom = true,
}) {
final flattened = <String>[];
final renameRegExp = RegExp('/\x00/');
for (final file in filePaths) {
if (renameRegExp.hasMatch(file)) {
final parts = file.split(renameRegExp);
if (parts.length < 2) {
logger
..err('Failed to process rename')
..detail('File: $file');
continue;
}
final [to, from, ...] = parts;
if (includeRenameFrom) flattened.add(from);
flattened.add(to);
} else {
flattened.add(file);
}
}
return flattened;
}