| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('git_source'); | 5 #library('git_source'); |
| 6 | 6 |
| 7 #import('io.dart'); | 7 #import('io.dart'); |
| 8 #import('package.dart'); | 8 #import('package.dart'); |
| 9 #import('source.dart'); | 9 #import('source.dart'); |
| 10 #import('source_registry.dart'); | 10 #import('source_registry.dart'); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * Clones the repo at the URI [from] to the path [to] on the local filesystem. | 149 * Clones the repo at the URI [from] to the path [to] on the local filesystem. |
| 150 * | 150 * |
| 151 * If [mirror] is true, create a bare, mirrored clone. This doesn't check out | 151 * If [mirror] is true, create a bare, mirrored clone. This doesn't check out |
| 152 * the working tree, but instead makes the repository a local mirror of the | 152 * the working tree, but instead makes the repository a local mirror of the |
| 153 * remote repository. See the manpage for `git clone` for more information. | 153 * remote repository. See the manpage for `git clone` for more information. |
| 154 */ | 154 */ |
| 155 Future _clone(String from, String to, [bool mirror=false]) { | 155 Future _clone(String from, String to, [bool mirror=false]) { |
| 156 var args = ["clone", from, to]; | 156 // Git on Windows does not seem to automatically create the destination |
| 157 if (mirror) args.insertRange(1, 1, "--mirror"); | 157 // directory. |
| 158 return runGit(args).transform((result) { | 158 return ensureDir(to).chain((_) { |
| 159 var args = ["clone", from, to]; |
| 160 if (mirror) args.insertRange(1, 1, "--mirror"); |
| 161 return runGit(args); |
| 162 }).transform((result) { |
| 159 if (!result.success) throw 'Git failed.'; | 163 if (!result.success) throw 'Git failed.'; |
| 160 return null; | 164 return null; |
| 161 }); | 165 }); |
| 162 } | 166 } |
| 163 | 167 |
| 164 /** | 168 /** |
| 165 * Checks out the reference [ref] in [repoPath]. | 169 * Checks out the reference [ref] in [repoPath]. |
| 166 */ | 170 */ |
| 167 Future _checkOut(String repoPath, String ref) { | 171 Future _checkOut(String repoPath, String ref) { |
| 168 return runGit(["checkout", ref], workingDir: repoPath).transform((result) { | 172 return runGit(["checkout", ref], workingDir: repoPath).transform((result) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 227 |
| 224 /** | 228 /** |
| 225 * Returns [description] if it's a description, or [PackageId.description] if | 229 * Returns [description] if it's a description, or [PackageId.description] if |
| 226 * it's a [PackageId]. | 230 * it's a [PackageId]. |
| 227 */ | 231 */ |
| 228 _getDescription(description) { | 232 _getDescription(description) { |
| 229 if (description is PackageId) return description.description; | 233 if (description is PackageId) return description.description; |
| 230 return description; | 234 return description; |
| 231 } | 235 } |
| 232 } | 236 } |
| OLD | NEW |