| Index: utils/pub/git_source.dart
|
| diff --git a/utils/pub/git_source.dart b/utils/pub/git_source.dart
|
| index 6327638d93ba54925cc3da600db4e351cab060dc..e54b6cf15226cf010f47c212686de8bca9bc3dfe 100644
|
| --- a/utils/pub/git_source.dart
|
| +++ b/utils/pub/git_source.dart
|
| @@ -11,9 +11,7 @@ import 'source.dart';
|
| import 'source_registry.dart';
|
| import 'utils.dart';
|
|
|
| -/**
|
| - * A package source that installs packages from Git repos.
|
| - */
|
| +/// A package source that installs packages from Git repos.
|
| class GitSource extends Source {
|
| final String name = "git";
|
|
|
| @@ -21,20 +19,18 @@ class GitSource extends Source {
|
|
|
| GitSource();
|
|
|
| - /**
|
| - * Clones a Git repo to the local filesystem.
|
| - *
|
| - * The Git cache directory is a little idiosyncratic. At the top level, it
|
| - * contains a directory for each commit of each repository, named `<package
|
| - * name>-<commit hash>`. These are the canonical package directories that are
|
| - * linked to from the `packages/` directory.
|
| - *
|
| - * In addition, the Git system cache contains a subdirectory named `cache/`
|
| - * which contains a directory for each separate repository URL, named
|
| - * `<package name>-<url hash>`. These are used to check out the repository
|
| - * itself; each of the commit-specific directories are clones of a directory
|
| - * in `cache/`.
|
| - */
|
| + /// Clones a Git repo to the local filesystem.
|
| + ///
|
| + /// The Git cache directory is a little idiosyncratic. At the top level, it
|
| + /// contains a directory for each commit of each repository, named `<package
|
| + /// name>-<commit hash>`. These are the canonical package directories that are
|
| + /// linked to from the `packages/` directory.
|
| + ///
|
| + /// In addition, the Git system cache contains a subdirectory named `cache/`
|
| + /// which contains a directory for each separate repository URL, named
|
| + /// `<package name>-<url hash>`. These are used to check out the repository
|
| + /// itself; each of the commit-specific directories are clones of a directory
|
| + /// in `cache/`.
|
| Future<Package> installToSystemCache(PackageId id) {
|
| var revisionCachePath;
|
|
|
| @@ -63,9 +59,7 @@ class GitSource extends Source {
|
| });
|
| }
|
|
|
| - /**
|
| - * Ensures [description] is a Git URL.
|
| - */
|
| + /// Ensures [description] is a Git URL.
|
| void validateDescription(description, {bool fromLockFile: false}) {
|
| // A single string is assumed to be a Git URL.
|
| if (description is String) return;
|
| @@ -85,9 +79,8 @@ class GitSource extends Source {
|
| }
|
| }
|
|
|
| - /**
|
| - * Two Git descriptions are equal if both their URLs and their refs are equal.
|
| - */
|
| + /// Two Git descriptions are equal if both their URLs and their refs are
|
| + /// equal.
|
| bool descriptionsEqual(description1, description2) {
|
| // TODO(nweiz): Do we really want to throw an error if you have two
|
| // dependencies on some repo, one of which specifies a ref and one of which
|
| @@ -96,9 +89,7 @@ class GitSource extends Source {
|
| _getRef(description1) == _getRef(description2);
|
| }
|
|
|
| - /**
|
| - * Attaches a specific commit to [id] to disambiguate it.
|
| - */
|
| + /// Attaches a specific commit to [id] to disambiguate it.
|
| Future<PackageId> resolveId(PackageId id) {
|
| return _revisionAt(id).transform((revision) {
|
| var description = {'url': _getUrl(id), 'ref': _getRef(id)};
|
| @@ -107,12 +98,10 @@ class GitSource extends Source {
|
| });
|
| }
|
|
|
| - /**
|
| - * Ensure that the canonical clone of the repository referred to by [id] (the
|
| - * one in `<system cache>/git/cache`) exists and is up-to-date. Returns a
|
| - * future that completes once this is finished and throws an exception if it
|
| - * fails.
|
| - */
|
| + /// Ensure that the canonical clone of the repository referred to by [id] (the
|
| + /// one in `<system cache>/git/cache`) exists and is up-to-date. Returns a
|
| + /// future that completes once this is finished and throws an exception if it
|
| + /// fails.
|
| Future _ensureRepoCache(PackageId id) {
|
| var path = _repoCachePath(id);
|
| return exists(path).chain((exists) {
|
| @@ -122,17 +111,13 @@ class GitSource extends Source {
|
| });
|
| }
|
|
|
| - /**
|
| - * Returns a future that completes to the revision hash of [id].
|
| - */
|
| + /// Returns a future that completes to the revision hash of [id].
|
| Future<String> _revisionAt(PackageId id) {
|
| return git.run(["rev-parse", _getEffectiveRef(id)],
|
| workingDir: _repoCachePath(id)).transform((result) => result[0]);
|
| }
|
|
|
| - /**
|
| - * Returns the path to the revision-specific cache of [id].
|
| - */
|
| + /// Returns the path to the revision-specific cache of [id].
|
| Future<String> _revisionCachePath(PackageId id) {
|
| return _revisionAt(id).transform((rev) {
|
| var revisionCacheName = '${id.name}-$rev';
|
| @@ -140,13 +125,12 @@ class GitSource extends Source {
|
| });
|
| }
|
|
|
| - /**
|
| - * Clones the repo at the URI [from] to the path [to] on the local filesystem.
|
| - *
|
| - * If [mirror] is true, create a bare, mirrored clone. This doesn't check out
|
| - * the working tree, but instead makes the repository a local mirror of the
|
| - * remote repository. See the manpage for `git clone` for more information.
|
| - */
|
| + /// Clones the repo at the URI [from] to the path [to] on the local
|
| + /// filesystem.
|
| + ///
|
| + /// If [mirror] is true, create a bare, mirrored clone. This doesn't check out
|
| + /// the working tree, but instead makes the repository a local mirror of the
|
| + /// remote repository. See the manpage for `git clone` for more information.
|
| Future _clone(String from, String to, {bool mirror: false}) {
|
| // Git on Windows does not seem to automatically create the destination
|
| // directory.
|
| @@ -157,43 +141,36 @@ class GitSource extends Source {
|
| }).transform((result) => null);
|
| }
|
|
|
| - /**
|
| - * Checks out the reference [ref] in [repoPath].
|
| - */
|
| + /// Checks out the reference [ref] in [repoPath].
|
| Future _checkOut(String repoPath, String ref) {
|
| return git.run(["checkout", ref], workingDir: repoPath).transform(
|
| (result) => null);
|
| }
|
|
|
| - /**
|
| - * Returns the path to the canonical clone of the repository referred to by
|
| - * [id] (the one in `<system cache>/git/cache`).
|
| - */
|
| + /// Returns the path to the canonical clone of the repository referred to by
|
| + /// [id] (the one in `<system cache>/git/cache`).
|
| String _repoCachePath(PackageId id) {
|
| var repoCacheName = '${id.name}-${sha1(_getUrl(id))}';
|
| return join(systemCacheRoot, 'cache', repoCacheName);
|
| }
|
|
|
| - /**
|
| - * Returns the repository URL for [id].
|
| - *
|
| - * [description] may be a description or a [PackageId].
|
| - */
|
| + /// Returns the repository URL for [id].
|
| + ///
|
| + /// [description] may be a description or a [PackageId].
|
| String _getUrl(description) {
|
| description = _getDescription(description);
|
| if (description is String) return description;
|
| return description['url'];
|
| }
|
|
|
| - /**
|
| - * Returns the commit ref that should be checked out for [description].
|
| - *
|
| - * This differs from [_getRef] in that it doesn't just return the ref in
|
| - * [description]. It will return a sensible default if that ref doesn't exist,
|
| - * and it will respect the "resolved-ref" parameter set by [resolveId].
|
| - *
|
| - * [description] may be a description or a [PackageId].
|
| - */
|
| + /// Returns the commit ref that should be checked out for [description].
|
| + ///
|
| + /// This differs from [_getRef] in that it doesn't just return the ref in
|
| + /// [description]. It will return a sensible default if that ref doesn't
|
| + /// exist, and it will respect the "resolved-ref" parameter set by
|
| + /// [resolveId].
|
| + ///
|
| + /// [description] may be a description or a [PackageId].
|
| String _getEffectiveRef(description) {
|
| description = _getDescription(description);
|
| if (description is Map && description.containsKey('resolved-ref')) {
|
| @@ -204,21 +181,17 @@ class GitSource extends Source {
|
| return ref == null ? 'HEAD' : ref;
|
| }
|
|
|
| - /**
|
| - * Returns the commit ref for [description], or null if none is given.
|
| - *
|
| - * [description] may be a description or a [PackageId].
|
| - */
|
| + /// Returns the commit ref for [description], or null if none is given.
|
| + ///
|
| + /// [description] may be a description or a [PackageId].
|
| String _getRef(description) {
|
| description = _getDescription(description);
|
| if (description is String) return null;
|
| return description['ref'];
|
| }
|
|
|
| - /**
|
| - * Returns [description] if it's a description, or [PackageId.description] if
|
| - * it's a [PackageId].
|
| - */
|
| + /// Returns [description] if it's a description, or [PackageId.description] if
|
| + /// it's a [PackageId].
|
| _getDescription(description) {
|
| if (description is PackageId) return description.description;
|
| return description;
|
|
|