Skip to content

Send dependency metadata to the hosted package server #1843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/src/solver/package_lister.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:pub_semver/pub_semver.dart';

import '../exceptions.dart';
import '../flutter.dart' as flutter;
import '../http.dart';
import '../log.dart' as log;
import '../package.dart';
import '../package_name.dart';
Expand Down Expand Up @@ -37,6 +38,9 @@ class PackageLister {
/// The source from which [_ref] comes.
final BoundSource _source;

/// The type of the dependency from the root package onto [_ref].
final DependencyType _dependencyType;

/// The set of package names that were overridden by the root package.
final Set<String> _overriddenPackages;

Expand Down Expand Up @@ -69,7 +73,8 @@ class PackageLister {

/// All versions of the package, sorted by [Version.compareTo].
Future<List<PackageId>> get _versions => _versionsMemo.runOnce(() async {
_cachedVersions = await _source.getVersions(_ref);
_cachedVersions = await withDependencyType(
_dependencyType, () => _source.getVersions(_ref));
_cachedVersions.sort((id1, id2) => id1.version.compareTo(id2.version));
return _cachedVersions;
});
Expand All @@ -82,8 +87,8 @@ class PackageLister {
final _latestMemo = new AsyncMemoizer<PackageId>();

/// Creates a package lister for the dependency identified by [ref].
PackageLister(
SystemCache cache, this._ref, this._locked, this._overriddenPackages,
PackageLister(SystemCache cache, this._ref, this._locked,
this._dependencyType, this._overriddenPackages,
{bool downgrade: false})
: _source = cache.source(_ref.source),
_isDowngrade = downgrade;
Expand All @@ -96,6 +101,7 @@ class PackageLister {
// boundaries of various constraints, which is useless for the root
// package.
_locked = new PackageId.root(package),
_dependencyType = DependencyType.none,
_overriddenPackages = const UnmodifiableSetView.empty(),
_isDowngrade = false;

Expand Down Expand Up @@ -164,7 +170,8 @@ class PackageLister {

Pubspec pubspec;
try {
pubspec = await _source.describe(id);
pubspec =
await withDependencyType(_dependencyType, () => _source.describe(id));
} on PubspecException catch (error) {
// The lockfile for the pubspec couldn't be parsed,
log.fine("Failed to parse pubspec for $id:\n$error");
Expand Down Expand Up @@ -388,7 +395,8 @@ class PackageLister {
/// keeping the actual error handling in a central location.
Future<Pubspec> _describeSafe(PackageId id) async {
try {
return await _source.describe(id);
return await withDependencyType(
_dependencyType, () => _source.describe(id));
} catch (_) {
return new Pubspec(id.name, version: id.version);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/solver/version_solver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ class VersionSolver {
overridden = new Set.from(overridden)..add(_root.name);
}

return new PackageLister(_systemCache, ref, locked, overridden,
return new PackageLister(_systemCache, ref, locked,
_root.dependencyType(package.name), overridden,
downgrade: _type == SolveType.DOWNGRADE);
});
}
Expand Down
2 changes: 0 additions & 2 deletions test/hosted/metadata_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

@Skip()

import 'dart:io';

import 'package:test/test.dart';
Expand Down