Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: utils/pub/git_source.dart

Issue 12280019: Revert "Support relative paths in path dependencies." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/entrypoint.dart ('k') | utils/pub/hosted_source.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'dart:async'; 7 import 'dart:async';
8 8
9 import '../../pkg/path/lib/path.dart' as path; 9 import '../../pkg/path/lib/path.dart' as path;
10 10
11 import 'git.dart' as git; 11 import 'git.dart' as git;
12 import 'io.dart'; 12 import 'io.dart';
13 import 'log.dart' as log;
14 import 'package.dart'; 13 import 'package.dart';
15 import 'source.dart'; 14 import 'source.dart';
16 import 'source_registry.dart'; 15 import 'source_registry.dart';
17 import 'utils.dart'; 16 import 'utils.dart';
18 17
19 /// A package source that installs packages from Git repos. 18 /// A package source that installs packages from Git repos.
20 class GitSource extends Source { 19 class GitSource extends Source {
21 final String name = "git"; 20 final String name = "git";
22 21
23 final bool shouldCache = true; 22 final bool shouldCache = true;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 }); 60 });
62 } 61 }
63 62
64 /// Returns the path to the revision-specific cache of [id]. 63 /// Returns the path to the revision-specific cache of [id].
65 Future<String> systemCacheDirectory(PackageId id) { 64 Future<String> systemCacheDirectory(PackageId id) {
66 return _revisionAt(id).then((rev) { 65 return _revisionAt(id).then((rev) {
67 var revisionCacheName = '${id.name}-$rev'; 66 var revisionCacheName = '${id.name}-$rev';
68 return path.join(systemCacheRoot, revisionCacheName); 67 return path.join(systemCacheRoot, revisionCacheName);
69 }); 68 });
70 } 69 }
71
72 /// Ensures [description] is a Git URL. 70 /// Ensures [description] is a Git URL.
73 dynamic parseDescription(String containingPath, description, 71 void validateDescription(description, {bool fromLockFile: false}) {
74 {bool fromLockFile: false}) {
75 // TODO(rnystrom): Handle git URLs that are relative file paths (#8570).
76 // A single string is assumed to be a Git URL. 72 // A single string is assumed to be a Git URL.
77 // TODO(rnystrom): Now that this function can modify the description, it 73 if (description is String) return;
78 // may as well canonicalize it to a map so that other code in the source
79 // can assume that.
80 if (description is String) return description;
81 if (description is! Map || !description.containsKey('url')) { 74 if (description is! Map || !description.containsKey('url')) {
82 throw new FormatException("The description must be a Git URL or a map " 75 throw new FormatException("The description must be a Git URL or a map "
83 "with a 'url' key."); 76 "with a 'url' key.");
84 } 77 }
78 description = new Map.from(description);
79 description.remove('url');
80 description.remove('ref');
81 if (fromLockFile) description.remove('resolved-ref');
85 82
86 var parsed = new Map.from(description); 83 if (!description.isEmpty) {
87 parsed.remove('url'); 84 var plural = description.length > 1;
88 parsed.remove('ref'); 85 var keys = description.keys.join(', ');
89 if (fromLockFile) parsed.remove('resolved-ref');
90
91 if (!parsed.isEmpty) {
92 var plural = parsed.length > 1;
93 var keys = parsed.keys.join(', ');
94 throw new FormatException("Invalid key${plural ? 's' : ''}: $keys."); 86 throw new FormatException("Invalid key${plural ? 's' : ''}: $keys.");
95 } 87 }
96
97 return description;
98 } 88 }
99 89
100 /// Two Git descriptions are equal if both their URLs and their refs are 90 /// Two Git descriptions are equal if both their URLs and their refs are
101 /// equal. 91 /// equal.
102 bool descriptionsEqual(description1, description2) { 92 bool descriptionsEqual(description1, description2) {
103 // TODO(nweiz): Do we really want to throw an error if you have two 93 // TODO(nweiz): Do we really want to throw an error if you have two
104 // dependencies on some repo, one of which specifies a ref and one of which 94 // dependencies on some repo, one of which specifies a ref and one of which
105 // doesn't? If not, how do we handle that case in the version solver? 95 // doesn't? If not, how do we handle that case in the version solver?
106 return _getUrl(description1) == _getUrl(description2) && 96 return _getUrl(description1) == _getUrl(description2) &&
107 _getRef(description1) == _getRef(description2); 97 _getRef(description1) == _getRef(description2);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return description['ref']; 190 return description['ref'];
201 } 191 }
202 192
203 /// Returns [description] if it's a description, or [PackageId.description] if 193 /// Returns [description] if it's a description, or [PackageId.description] if
204 /// it's a [PackageId]. 194 /// it's a [PackageId].
205 _getDescription(description) { 195 _getDescription(description) {
206 if (description is PackageId) return description.description; 196 if (description is PackageId) return description.description;
207 return description; 197 return description;
208 } 198 }
209 } 199 }
OLDNEW
« no previous file with comments | « utils/pub/entrypoint.dart ('k') | utils/pub/hosted_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698