Future main()

in Utils/status_files_checker.dart [8:69]


Future<int> main(List<String> args) async {
  Options options;
  try {
    options = Options.read(args);
  } on EmptyOptionsException {
    return 0;
  } on OptionsException catch (e) {
    print(e.text);
    return 1;
  }

  Map<String, List<String>> map;
  try {
    map = findAndReadStatusFiles(options.sdk);
  } on StatusFilesException catch (e) {
    print(e.text);
    return -1;
  }
  List<String> arguments = [
    'log',
    '--pretty=format:"%h"',
    '--after=${options.after}',
    if (options.before != null) '--before=${options.before}'
  ];
  ProcessResult res = await Process.run('git', arguments);
  if (res.exitCode != 0) {
    print(res.stderr);
    return 2;
  }
  int foundCount = 0;
  List<String> commits = (res.stdout as String).split("\n");
  for (var c in commits) {
    if (c.isEmpty) {
      continue;
    }
    c = c.replaceAll('"', '');
    ProcessResult r = await Process.run(
        'git', ['show', '--pretty=format:""', '--name-only', c]);
    if (r.exitCode != 0) {
      print(r.stderr);
      return 3;
    }
    List files = (r.stdout as String).split("\n");
    for (String f in files) {
      if (f.isEmpty) {
        continue;
      }
      if (f.endsWith(".dart")) {
        String testName = f.substring(0, f.indexOf(".dart"));
        var found = map[testName];
        if (found != null) {
          print(
              "Test $testName was changed in commit $c and presents in the following status files");
          print(found);
          foundCount++;
        }
      }
    }
  }
  print("$foundCount status files entries was found in ${commits.length} commits");
  return 0;
}