| Index: utils/tests/pub/test_pub.dart
|
| diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart
|
| index 6b464097bf8060229758efe2f770a59d02d713ef..5a018c611901313f3228b0eb8515d942fe5d9f06 100644
|
| --- a/utils/tests/pub/test_pub.dart
|
| +++ b/utils/tests/pub/test_pub.dart
|
| @@ -992,30 +992,21 @@ class GitRepoDescriptor extends DirectoryDescriptor {
|
| * Creates the Git repository and commits the contents.
|
| */
|
| Future<Directory> create(parentDir) {
|
| - var workingDir;
|
| - Future runGit(List<String> args) => _runGit(args, workingDir);
|
| -
|
| - return super.create(parentDir).chain((rootDir) {
|
| - workingDir = rootDir;
|
| - return runGit(['init']);
|
| - }).chain((_) => runGit(['add', '.']))
|
| - .chain((_) => runGit(['commit', '-m', 'initial commit',
|
| - '--author="Pub Test <pub@dartlang.org>"']))
|
| - .transform((_) => workingDir);
|
| + return _runGitCommands(parentDir, [
|
| + ['init'],
|
| + ['add', '.'],
|
| + ['commit', '-m', 'initial commit']
|
| + ]);
|
| }
|
|
|
| /**
|
| * Commits any changes to the Git repository.
|
| */
|
| Future commit(parentDir) {
|
| - var workingDir;
|
| - Future runGit(List<String> args) => _runGit(args, workingDir);
|
| -
|
| - return super.create(parentDir).chain((rootDir) {
|
| - workingDir = rootDir;
|
| - return runGit(['add', '.']);
|
| - }).chain((_) => runGit(['commit', '-m', 'update',
|
| - '--author="Pub Test <pub@dartlang.org>"']));
|
| + return _runGitCommands(parentDir, [
|
| + ['add', '.'],
|
| + ['commit', '-m', 'update']
|
| + ]);
|
| }
|
|
|
| /**
|
| @@ -1029,10 +1020,8 @@ class GitRepoDescriptor extends DirectoryDescriptor {
|
| */
|
| Future<String> revParse(String ref) {
|
| var completer = new Completer<String>();
|
| - // TODO(nweiz): inline this once issue 3197 is fixed
|
| - var superCreate = super.create;
|
| _schedule((parentDir) {
|
| - return superCreate(parentDir).chain((rootDir) {
|
| + return super.create(parentDir).chain((rootDir) {
|
| return _runGit(['rev-parse', ref], rootDir);
|
| }).transform((output) {
|
| completer.complete(output[0]);
|
| @@ -1050,6 +1039,25 @@ class GitRepoDescriptor extends DirectoryDescriptor {
|
| });
|
| }
|
|
|
| + Future _runGitCommands(String parentDir, List<List<String>> commands) {
|
| + var workingDir;
|
| +
|
| + Future runGitStep(_) {
|
| + if (commands.isEmpty) return new Future.immediate(workingDir);
|
| + var command = commands.removeAt(0);
|
| + return _runGit(command, workingDir).chain(runGitStep);
|
| + }
|
| +
|
| + return super.create(parentDir).chain((rootDir) {
|
| + workingDir = rootDir;
|
| + return writeTextFile(join(parentDir, '.gitconfig'), '''
|
| +[user]
|
| + name = Test Pub
|
| + email = pub@dartlang.org
|
| +''');
|
| + }).chain(runGitStep);
|
| + }
|
| +
|
| Future<String> _runGit(List<String> args, Directory workingDir) {
|
| return runGit(args, workingDir: workingDir.path).transform((result) {
|
| if (!result.success) {
|
|
|