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

Side by Side Diff: lib/src/validator/dependency.dart

Issue 2044253003: Refactor Source and SourceRegistry. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Rename LiveSource to BoundSource. Created 4 years, 6 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
« no previous file with comments | « lib/src/system_cache.dart ('k') | test/dependency_computer/utils.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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:pub_semver/pub_semver.dart'; 7 import 'package:pub_semver/pub_semver.dart';
8 8
9 import '../entrypoint.dart'; 9 import '../entrypoint.dart';
10 import '../log.dart' as log; 10 import '../log.dart' as log;
11 import '../package.dart'; 11 import '../package.dart';
12 import '../source/hosted.dart';
13 import '../validator.dart'; 12 import '../validator.dart';
14 13
15 /// The range of all pub versions that don't support `^` version constraints. 14 /// The range of all pub versions that don't support `^` version constraints.
16 /// 15 ///
17 /// This is the actual range of pub versions, whereas [_postCaretPubVersions] is 16 /// This is the actual range of pub versions, whereas [_postCaretPubVersions] is
18 /// the nicer-looking range that doesn't include a prerelease tag. 17 /// the nicer-looking range that doesn't include a prerelease tag.
19 final _preCaretPubVersions = new VersionConstraint.parse("<1.8.0-dev.3.0"); 18 final _preCaretPubVersions = new VersionConstraint.parse("<1.8.0-dev.3.0");
20 19
21 /// The range of all pub versions that do support `^` version constraints. 20 /// The range of all pub versions that do support `^` version constraints.
22 /// 21 ///
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 58
60 if (caretDeps.isNotEmpty && !_caretAllowed) { 59 if (caretDeps.isNotEmpty && !_caretAllowed) {
61 _errorAboutCaretConstraints(caretDeps); 60 _errorAboutCaretConstraints(caretDeps);
62 } 61 }
63 } 62 }
64 63
65 /// Warn that dependencies should use the hosted source. 64 /// Warn that dependencies should use the hosted source.
66 Future _warnAboutSource(PackageDep dep) async { 65 Future _warnAboutSource(PackageDep dep) async {
67 var versions; 66 var versions;
68 try { 67 try {
69 var ids = await entrypoint.cache.sources['hosted'] 68 var ids = await entrypoint.cache.hosted
70 .getVersions(HostedSource.refFor(dep.name)); 69 .getVersions(entrypoint.cache.sources.hosted.refFor(dep.name));
71 versions = ids.map((id) => id.version).toList(); 70 versions = ids.map((id) => id.version).toList();
72 } catch (error) { 71 } catch (error) {
73 versions = []; 72 versions = [];
74 } 73 }
75 74
76 var constraint; 75 var constraint;
77 var primary = Version.primary(versions); 76 var primary = Version.primary(versions);
78 if (primary != null) { 77 if (primary != null) {
79 constraint = _constraintForVersion(primary); 78 constraint = _constraintForVersion(primary);
80 } else { 79 } else {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 errors.add(buffer.toString().trim()); 206 errors.add(buffer.toString().trim());
208 } 207 }
209 208
210 /// Returns the suggested version constraint for a dependency that was tested 209 /// Returns the suggested version constraint for a dependency that was tested
211 /// against [version]. 210 /// against [version].
212 String _constraintForVersion(Version version) { 211 String _constraintForVersion(Version version) {
213 if (_caretAllowed) return "^$version"; 212 if (_caretAllowed) return "^$version";
214 return '">=$version <${version.nextBreaking}"'; 213 return '">=$version <${version.nextBreaking}"';
215 } 214 }
216 } 215 }
OLDNEW
« no previous file with comments | « lib/src/system_cache.dart ('k') | test/dependency_computer/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698