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

Unified Diff: sdk/lib/_internal/pub/lib/src/global_packages.dart

Issue 448933002: Support Git in pub global activate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise! Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/lib/src/global_packages.dart
diff --git a/sdk/lib/_internal/pub/lib/src/global_packages.dart b/sdk/lib/_internal/pub/lib/src/global_packages.dart
index 0baa6502ab66a71c47fa033d0cfefd07c42500eb..f2828ecf215330977f05c61119b1e33ae5c96c47 100644
--- a/sdk/lib/_internal/pub/lib/src/global_packages.dart
+++ b/sdk/lib/_internal/pub/lib/src/global_packages.dart
@@ -16,8 +16,8 @@ import 'log.dart' as log;
import 'package.dart';
import 'system_cache.dart';
import 'solver/version_solver.dart';
-import 'source.dart';
import 'source/cached.dart';
+import 'source/git.dart';
import 'source/path.dart';
import 'utils.dart';
import 'version.dart';
@@ -60,6 +60,19 @@ class GlobalPackages {
/// when needed.
GlobalPackages(this.cache);
+ /// Caches the package located in the Git repository [repo] and makes it the
+ /// active global version.
+ Future activateGit(String repo) {
+ var source = cache.sources["git"] as GitSource;
+ return source.getPackageNameFromRepo(repo).then((name) {
+ // Call this just to log what the current active package is, if any.
+ _describeActive(name);
+
+ var id = new PackageId(name, "git", Version.none, repo);
+ return _installInCache(id);
+ });
+ }
+
/// Finds the latest version of the hosted package with [name] that matches
/// [constraint] and makes it the active global version.
Future activateHosted(String name, VersionConstraint constraint) {
@@ -155,7 +168,11 @@ class GlobalPackages {
writeTextFile(_getLockFilePath(id.name),
lockFile.serialize(cache.rootDir, cache.sources));
- if (id.source == "path") {
+ if (id.source == "git") {
+ var url = GitSource.urlFromDescription(id.description);
+ log.message('Activated ${log.bold(id.name)} ${id.version} from Git '
+ 'repository "$url".');
+ } else if (id.source == "path") {
var path = PathSource.pathFromDescription(id.description);
log.message('Activated ${log.bold(id.name)} ${id.version} at path '
'"$path".');
@@ -174,7 +191,11 @@ class GlobalPackages {
cache.sources);
var id = lockFile.packages[package];
- if (id.source == "path") {
+ if (id.source == "git") {
+ var url = GitSource.urlFromDescription(id.description);
+ log.message('Package ${log.bold(id.name)} is currently active from '
+ 'Git repository "${url}".');
+ } else if (id.source == "path") {
var path = PathSource.pathFromDescription(id.description);
log.message('Package ${log.bold(package)} is currently active at '
'path "$path".');
@@ -204,7 +225,11 @@ class GlobalPackages {
deleteEntry(lockFilePath);
if (logDeactivate) {
- if (id.source == "path") {
+ if (id.source == "git") {
+ var url = GitSource.urlFromDescription(id.description);
+ log.message('Deactivated package ${log.bold(name)} from Git repository '
+ '"$url".');
+ } else if (id.source == "path") {
var path = PathSource.pathFromDescription(id.description);
log.message('Deactivated package ${log.bold(name)} at path "$path".');
} else {

Powered by Google App Engine
This is Rietveld 408576698