getUnifiedDiff method

Future<String> getUnifiedDiff(
  1. String baseRef, {
  2. List<String> targetPaths = const [],
})

Returns the raw unified diff between baseRef and the working tree.

Implementation

Future<String> getUnifiedDiff(
  String baseRef, {
  List<String> targetPaths = const [],
}) async {
  final args = ['diff', baseRef, '--', ...targetPaths];
  final res = await _runGit(args);
  if (res.exitCode != 0) {
    throw ArgumentError(
      'Git diff failed against base ref "$baseRef": '
      '${(res.stderr as String).trim()}',
    );
  }
  return res.stdout as String;
}