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:pub/src/git.dart' as git; | 10 import 'package:pub/src/git.dart' as git; |
11 import 'package:scheduled_test/scheduled_test.dart'; | 11 import 'package:scheduled_test/scheduled_test.dart'; |
12 import 'package:scheduled_test/descriptor.dart'; | 12 import 'package:scheduled_test/descriptor.dart'; |
13 | 13 |
14 /// Describes a Git repository and its contents. | 14 /// Describes a Git repository and its contents. |
15 class GitRepoDescriptor extends DirectoryDescriptor { | 15 class GitRepoDescriptor extends DirectoryDescriptor { |
16 GitRepoDescriptor(String name, List<Descriptor> contents) | 16 GitRepoDescriptor(String name, List<Descriptor> contents) |
17 : super(name, contents); | 17 : super(name, contents); |
18 | 18 |
19 /// Creates the Git repository and commits the contents. | 19 /// Creates the Git repository and commits the contents. |
20 Future create([String parent]) => schedule(() { | 20 Future create([String parent]) => schedule(() { |
21 return super.create(parent).then((_) { | 21 return super.create(parent).then((_) { |
22 return _runGitCommands(parent, [ | 22 return _runGitCommands(parent, [ |
23 ['init'], | 23 ['init'], |
24 ['add', '.'], | 24 ['add', '.'], |
25 ['commit', '-m', 'initial commit'] | 25 ['commit', '-m', 'initial commit', '--allow-empty'] |
26 ]); | 26 ]); |
27 }); | 27 }); |
28 }, 'creating Git repo:\n${describe()}'); | 28 }, 'creating Git repo:\n${describe()}'); |
29 | 29 |
30 /// Writes this descriptor to the filesystem, than commits any changes from | 30 /// Writes this descriptor to the filesystem, than commits any changes from |
31 /// the previous structure to the Git repo. | 31 /// the previous structure to the Git repo. |
32 /// | 32 /// |
33 /// [parent] defaults to [defaultRoot]. | 33 /// [parent] defaults to [defaultRoot]. |
34 Future commit([String parent]) => schedule(() { | 34 Future commit([String parent]) => schedule(() { |
35 return super.create(parent).then((_) { | 35 return super.create(parent).then((_) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 'GIT_COMMITTER_EMAIL': 'pub@dartlang.org' | 68 'GIT_COMMITTER_EMAIL': 'pub@dartlang.org' |
69 }; | 69 }; |
70 | 70 |
71 if (parent == null) parent = defaultRoot; | 71 if (parent == null) parent = defaultRoot; |
72 return git.run(args, | 72 return git.run(args, |
73 workingDir: path.join(parent, name), | 73 workingDir: path.join(parent, name), |
74 environment: environment); | 74 environment: environment); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
OLD | NEW |