| 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 library descriptor.git; | 5 library descriptor.git; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
| 10 import 'package:scheduled_test/scheduled_test.dart'; | 10 import 'package:scheduled_test/scheduled_test.dart'; |
| 11 import 'package:scheduled_test/descriptor.dart'; | 11 import 'package:scheduled_test/descriptor.dart'; |
| 12 | 12 |
| 13 import '../../lib/src/git.dart' as git; | 13 import '../../lib/src/git.dart' as git; |
| 14 | 14 |
| 15 /// Describes a Git repository and its contents. | 15 /// Describes a Git repository and its contents. |
| 16 class GitRepoDescriptor extends DirectoryDescriptor { | 16 class GitRepoDescriptor extends DirectoryDescriptor { |
| 17 GitRepoDescriptor(String name, List<Descriptor> contents) | 17 GitRepoDescriptor(String name, List<Descriptor> contents) |
| 18 : super(name, contents); | 18 : super(name, contents); |
| 19 | 19 |
| 20 /// Creates the Git repository and commits the contents. | 20 /// Creates the Git repository and commits the contents. |
| 21 Future create([String parent]) => schedule(() { | 21 Future create([String parent]) => schedule(() { |
| 22 return super.create(parent).then((_) { | 22 return super.create(parent).then((_) { |
| 23 return _runGitCommands(parent, [ | 23 return _runGitCommands( |
| 24 ['init'], | 24 parent, |
| 25 ['add', '.'], | 25 [['init'], ['add', '.'], ['commit', '-m', 'initial commit']]); |
| 26 ['commit', '-m', 'initial commit'] | |
| 27 ]); | |
| 28 }); | 26 }); |
| 29 }, 'creating Git repo:\n${describe()}'); | 27 }, 'creating Git repo:\n${describe()}'); |
| 30 | 28 |
| 31 /// Writes this descriptor to the filesystem, than commits any changes from | 29 /// Writes this descriptor to the filesystem, than commits any changes from |
| 32 /// the previous structure to the Git repo. | 30 /// the previous structure to the Git repo. |
| 33 /// | 31 /// |
| 34 /// [parent] defaults to [defaultRoot]. | 32 /// [parent] defaults to [defaultRoot]. |
| 35 Future commit([String parent]) => schedule(() { | 33 Future commit([String parent]) => schedule(() { |
| 36 return super.create(parent).then((_) { | 34 return super.create(parent).then((_) { |
| 37 return _runGitCommands(parent, [ | 35 return _runGitCommands( |
| 38 ['add', '.'], | 36 parent, |
| 39 ['commit', '-m', 'update'] | 37 [['add', '.'], ['commit', '-m', 'update']]); |
| 40 ]); | |
| 41 }); | 38 }); |
| 42 }, 'committing Git repo:\n${describe()}'); | 39 }, 'committing Git repo:\n${describe()}'); |
| 43 | 40 |
| 44 /// 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 |
| 45 /// 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. |
| 46 /// | 43 /// |
| 47 /// [parent] defaults to [defaultRoot]. | 44 /// [parent] defaults to [defaultRoot]. |
| 48 Future<String> revParse(String ref, [String parent]) => schedule(() { | 45 Future<String> revParse(String ref, [String parent]) => schedule(() { |
| 49 return _runGit(['rev-parse', ref], parent).then((output) => output[0]); | 46 return _runGit(['rev-parse', ref], parent).then((output) => output[0]); |
| 50 }, 'parsing revision $ref for Git repo:\n${describe()}'); | 47 }, 'parsing revision $ref for Git repo:\n${describe()}'); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 63 // Explicitly specify the committer information. Git needs this to commit | 60 // Explicitly specify the committer information. Git needs this to commit |
| 64 // and we don't want to rely on the buildbots having this already set up. | 61 // and we don't want to rely on the buildbots having this already set up. |
| 65 var environment = { | 62 var environment = { |
| 66 'GIT_AUTHOR_NAME': 'Pub Test', | 63 'GIT_AUTHOR_NAME': 'Pub Test', |
| 67 'GIT_AUTHOR_EMAIL': 'pub@dartlang.org', | 64 'GIT_AUTHOR_EMAIL': 'pub@dartlang.org', |
| 68 'GIT_COMMITTER_NAME': 'Pub Test', | 65 'GIT_COMMITTER_NAME': 'Pub Test', |
| 69 'GIT_COMMITTER_EMAIL': 'pub@dartlang.org' | 66 'GIT_COMMITTER_EMAIL': 'pub@dartlang.org' |
| 70 }; | 67 }; |
| 71 | 68 |
| 72 if (parent == null) parent = defaultRoot; | 69 if (parent == null) parent = defaultRoot; |
| 73 return git.run(args, | 70 return git.run( |
| 71 args, |
| 74 workingDir: path.join(parent, name), | 72 workingDir: path.join(parent, name), |
| 75 environment: environment); | 73 environment: environment); |
| 76 } | 74 } |
| 77 } | 75 } |
| 78 | 76 |
| OLD | NEW |