applyModifications method
Implementation
Future<void> applyModifications(List<String> existing) async {
if (!await hasAtLeastOneCommit()) {
return;
}
logger.detail('Checking for modifications');
final changed = await nonStagedFiles() ?? [];
final allDeletedFiles = await getDeletedFiles();
if (changed.isEmpty && allDeletedFiles.isEmpty) {
logger.detail('No post file modifications were found');
return;
}
logger.detail('Pre-Task files: (${existing.length})');
for (final file in existing) {
logger.detail(' - $file');
}
logger.detail('Post-Task files: (${changed.length})');
for (final file in changed) {
logger.detail(' - $file');
}
logger.detail('Post-Deleted Files (${allDeletedFiles.length})');
for (final file in allDeletedFiles) {
logger.detail(' - $file');
}
final modifiedFiles = changed.toSet().difference(existing.toSet());
logger.detail('Found ${modifiedFiles.length} files modified or created');
for (final file in modifiedFiles) {
logger.detail(' - $file');
}
final deletedFiles = allDeletedFiles.toSet().difference(existing.toSet());
logger.detail('Found ${deletedFiles.length} deleted files to add');
for (final file in deletedFiles) {
logger.detail(' - $file');
}
final filesToAdd = modifiedFiles.followedBy(deletedFiles);
if (filesToAdd.isEmpty) {
logger.detail('Nothing to add to commit');
return;
}
await add(filesToAdd.toList());
}