commitFile function
Commit the file with a name in the test directory
Implementation
Future<void> commitFile(
Directory testDir,
String fileName, {
String message = 'Commit Message',
bool stage = true,
bool ammend = false,
}) async {
final nothingHasChanged = (await modifiedFiles(testDir)).isEmpty;
if (nothingHasChanged) {
return;
}
if (stage) {
await stageFile(testDir, fileName);
}
final result2 = await Process.run('git', [
'commit',
'-m',
message,
if (ammend) '--amend',
], workingDirectory: testDir.path);
_throw('Could not commit $fileName', result2);
}