| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * A package source that installs packages from Git repos. | |
| 7 */ | |
| 8 class GitSource extends Source { | |
| 9 final String name = "git"; | |
| 10 | |
| 11 // TODO(nweiz): this should be cached since it uses the network, but until we | |
| 12 // support versions there's no good way to distinguish between different | |
| 13 // checkouts of the same repository. | |
| 14 final bool shouldCache = false; | |
| 15 | |
| 16 GitSource(); | |
| 17 | |
| 18 /** | |
| 19 * Clones a Git repo to the local filesystem. | |
| 20 */ | |
| 21 Future<bool> install(PackageId id, String destPath) { | |
| 22 return runProcess("git", ["clone", "--progress", id.fullName, destPath], | |
| 23 pipeStdout: true, pipeStderr: true). | |
| 24 transform((result) => result.success); | |
| 25 } | |
| 26 | |
| 27 /** | |
| 28 * The package name of a Git repo is the name of the directory into which | |
| 29 * it'll be cloned. | |
| 30 */ | |
| 31 String packageName(PackageId id) => | |
| 32 basename(id.fullName).replaceFirst(const RegExp("\.git\$"), ""); | |
| 33 } | |
| OLD | NEW |