stash method

Future<int?> stash()

Implementation

Future<int?> stash() async {
  final stashes = await Process.run('git', ['stash', 'list']);

  final out = switch (stashes.stdout) {
    final String stashes => stashes,
    _ => null,
  };

  if (out == null) {
    logger
      ..err('Failed to get stashes')
      ..detail('Error: ${stashes.stderr}');
    return null;
  }

  for (final (index, line) in out.split('\n').indexed) {
    if (!line.contains(_stashMessage)) continue;

    return index;
  }

  return null;
}