createStash method
Implementation
Future<String> createStash() async {
final result = await Process.run('git', ['stash', 'create']);
final hash = switch (result.stdout) {
final String hash => hash.trim(),
_ => null,
};
if (hash == null) {
logger
..err('Failed to create stash')
..detail('Error: ${result.stderr}');
throw Exception('Failed to create stash');
}
// dart is running to fast for git to cache the stash,
// resulting in a error throwing race condition
await Future<void>.delayed(const Duration(milliseconds: 100));
final storeResult = await Process.run(
'git',
[
'stash',
'store',
'--message',
'"$_stashMessage"',
hash,
],
);
if (storeResult.exitCode != 0) {
logger
..err('Failed to store stash')
..detail('Error: ${storeResult.stderr}');
throw Exception('Failed to store stash');
}
return hash;
}