| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
| 8 import 'package:pub/src/git.dart' as git; | 8 import 'package:pub/src/git.dart' as git; |
| 9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
| 10 import 'package:scheduled_test/descriptor.dart'; | 10 import 'package:scheduled_test/descriptor.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 ['add', '.'], | 35 ['add', '.'], |
| 36 ['commit', '-m', 'update'] | 36 ['commit', '-m', 'update'] |
| 37 ]); | 37 ]); |
| 38 }); | 38 }); |
| 39 }, 'committing Git repo:\n${describe()}'); | 39 }, 'committing Git repo:\n${describe()}'); |
| 40 | 40 |
| 41 /// Return a Future that completes to the commit in the git repository | 41 /// Return a Future that completes to the commit in the git repository |
| 42 /// referred to by [ref] at the current point in the scheduled test run. | 42 /// referred to by [ref] at the current point in the scheduled test run. |
| 43 /// | 43 /// |
| 44 /// [parent] defaults to [defaultRoot]. | 44 /// [parent] defaults to [defaultRoot]. |
| 45 Future<String> revParse(String ref, [String parent]) => schedule(() { | 45 Future<String> revParse(String ref, [String parent]) { |
| 46 return _runGit(['rev-parse', ref], parent).then((output) => output[0]); | 46 return schedule/*<Future<String>>*/(() async { |
| 47 }, 'parsing revision $ref for Git repo:\n${describe()}'); | 47 var output = await _runGit(['rev-parse', ref], parent); |
| 48 return output[0]; |
| 49 }, 'parsing revision $ref for Git repo:\n${describe()}'); |
| 50 } |
| 48 | 51 |
| 49 /// Schedule a Git command to run in this repository. | 52 /// Schedule a Git command to run in this repository. |
| 50 /// | 53 /// |
| 51 /// [parent] defaults to [defaultRoot]. | 54 /// [parent] defaults to [defaultRoot]. |
| 52 Future runGit(List<String> args, [String parent]) => schedule(() { | 55 Future runGit(List<String> args, [String parent]) => schedule(() { |
| 53 return _runGit(args, parent); | 56 return _runGit(args, parent); |
| 54 }, "running 'git ${args.join(' ')}' in Git repo:\n${describe()}"); | 57 }, "running 'git ${args.join(' ')}' in Git repo:\n${describe()}"); |
| 55 | 58 |
| 56 Future _runGitCommands(String parent, List<List<String>> commands) => | 59 Future _runGitCommands(String parent, List<List<String>> commands) async { |
| 57 Future.forEach(commands, (command) => _runGit(command, parent)); | 60 for (var command in commands) { |
| 61 await _runGit(command, parent); |
| 62 } |
| 63 } |
| 58 | 64 |
| 59 Future<List<String>> _runGit(List<String> args, String parent) { | 65 Future<List<String>> _runGit(List<String> args, String parent) { |
| 60 // Explicitly specify the committer information. Git needs this to commit | 66 // Explicitly specify the committer information. Git needs this to commit |
| 61 // and we don't want to rely on the buildbots having this already set up. | 67 // and we don't want to rely on the buildbots having this already set up. |
| 62 var environment = { | 68 var environment = { |
| 63 'GIT_AUTHOR_NAME': 'Pub Test', | 69 'GIT_AUTHOR_NAME': 'Pub Test', |
| 64 'GIT_AUTHOR_EMAIL': 'pub@dartlang.org', | 70 'GIT_AUTHOR_EMAIL': 'pub@dartlang.org', |
| 65 'GIT_COMMITTER_NAME': 'Pub Test', | 71 'GIT_COMMITTER_NAME': 'Pub Test', |
| 66 'GIT_COMMITTER_EMAIL': 'pub@dartlang.org' | 72 'GIT_COMMITTER_EMAIL': 'pub@dartlang.org' |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 if (parent == null) parent = defaultRoot; | 75 if (parent == null) parent = defaultRoot; |
| 70 return git.run(args, | 76 return git.run(args, |
| 71 workingDir: path.join(parent, name), | 77 workingDir: path.join(parent, name), |
| 72 environment: environment); | 78 environment: environment); |
| 73 } | 79 } |
| 74 } | 80 } |
| 75 | 81 |
| OLD | NEW |