Permalink
Browse files

Merge branch 'verbose-list'

  • Loading branch information...
2 parents 7d693fc + 5ea91f8 commit 506a8f7c6772f97053477b8f4c7d56b5838af7cb @japhb japhb committed Aug 21, 2012
Showing with 46 additions and 20 deletions.
  1. +0 −6 TODO
  2. +28 −10 bin/panda
  3. +10 −2 lib/Panda/Ecosystem.pm
  4. +8 −2 lib/Panda/Fetcher.pm
View
6 TODO
@@ -1,12 +1,6 @@
* Support DESTDIR as way to build deployable package
- don't modify statefile when DESTDIR is set unless DESTDIR is ~/.perl6/
- envvar to use a different statefile?
-* Finish verbose-list branch
- - save 'git describe --always --dirty' result in saved-meta
- - make 'panda list' output narrower by default
- . with a --verbose option for more?
- - show both installed and available version in 'panda list' or 'panda info'
- - merge branch back
* Open GitHub issues:
- #4: Fix fetcher.t to silence (expected) Git error message
- #12: Error checking for Ecosystem::update
View
@@ -2,13 +2,15 @@
use Shell::Command;
use Panda;
-sub listprojects($panda, :$installed) {
+sub listprojects($panda, :$installed, :$verbose) {
my $es = $panda.ecosystem;
my @projects = $es.project-list.sort.map: { $es.get-project($_) };
@projects .= grep({ $es.project-get-state($_) ne 'absent' })
if $installed;
+ my @saved = @projects.map({ $es.project-get-saved-meta($_) || {} });
my $max-name = @projects».name».chars.max;
my $max-ver = @projects».version».chars.max;
+ my $max-rev = @saved.map({ $_<source-revision> // '?'})».chars.max;
for @projects -> $x {
my $s = do given $es.project-get-state($x) {
@@ -17,9 +19,19 @@ sub listprojects($panda, :$installed) {
default { '' }
}
- my $url = $x.metainfo<source-url> // $x.metainfo<repo-url> // 'UNKNOWN';
- printf "%-{$max-name}s %-{$max-ver}s %-12s %s\n",
- $x.name, $x.version, $s, $url;
+ my $meta = $s ?? $es.project-get-saved-meta($x) !! $x.metainfo;
+ my $url = $meta<source-url> // $meta<repo-url> // 'UNKNOWN';
+ my $rev = $meta<source-revision> // '?';
+ my $ver = $meta<version>;
+
+ if ($verbose) {
+ printf "%-{$max-name}s %-12s %-{$max-ver}s %-{$max-rev}s %s\n",
+ $x.name, $s, $ver, $rev, $url;
+ }
+ else {
+ printf "%-{$max-name}s %-12s\n",
+ $x.name, $s;
+ }
}
}
@@ -39,21 +51,27 @@ sub projectinfo($panda, @args) {
for @args -> $p {
my $x = $panda.ecosystem.get-project($p);
if $x {
+ my $state = $panda.ecosystem.project-get-state($x);
+ say 'PROJECT LIST:';
say $x.name => $x.version;
- say "Depends on:" => $x.dependencies.Str if $x.dependencies;
- given $panda.ecosystem.project-get-state($x) {
+ say 'Depends on:' => $x.dependencies.Str if $x.dependencies;
+ given $state {
when 'installed' {
- say "State:\t\tinstalled";
+ say 'State' => 'installed';
}
when 'installed-dep' {
- say "State:\t\tinstalled as a dependency";
+ say 'State' => 'installed as a dependency';
}
}
for $x.metainfo.kv -> $k, $v {
if $k ~~ none('version', 'name', 'depends') {
say $k.ucfirst => $v;
}
}
+ if $state ~~ /^ 'installed' / {
+ say 'INSTALLED VERSION:';
+ .say for $panda.ecosystem.project-get-saved-meta($x).pairs.sort;
+ }
say '';
} else {
say "Project '$p' not found"
@@ -98,8 +116,8 @@ multi MAIN ('install', *@modules, Bool :$notests, Bool :$nodeps) {
}
#= List all available modules
-multi MAIN ('list', Bool :$installed) {
- listprojects($panda, :$installed);
+multi MAIN ('list', Bool :$installed, Bool :$verbose) {
+ listprojects($panda, :$installed, :$verbose);
}
#= Update the module database
View
@@ -7,6 +7,7 @@ class Panda::Ecosystem does Pies::Ecosystem {
has $.projectsfile;
has %!projects;
has %!states;
+ has %!saved-meta;
sub getfile($src, $dest) {
pir::load_bytecode__vs('LWP/UserAgent.pir');
@@ -41,7 +42,8 @@ class Panda::Ecosystem does Pies::Ecosystem {
method flush-states {
my $fh = open($!statefile, :w);
for %!states.kv -> $key, $val {
- $fh.say: "$key $val";
+ my $json = to-json %!saved-meta{$key};
+ $fh.say: "$key $val $json";
}
$fh.close;
}
@@ -50,8 +52,9 @@ class Panda::Ecosystem does Pies::Ecosystem {
if $!statefile.IO ~~ :f {
my $fh = open($!statefile);
for $fh.lines -> $line {
- my ($mod, $state) = split ' ', $line;
+ my ($mod, $state, $json) = split ' ', $line, 3;
%!states{$mod} = $state;
+ %!saved-meta{$mod} = from-json $json;
}
}
@@ -95,9 +98,14 @@ class Panda::Ecosystem does Pies::Ecosystem {
%!states{$p.name} // 'absent'
}
+ method project-get-saved-meta(Pies::Project $p) {
+ %!saved-meta{$p.name};
+ }
+
method project-set-state(Pies::Project $p,
Pies::Project::State $s) {
%!states{$p.name} = $s;
+ %!saved-meta{$p.name} = $p.metainfo;
self.flush-states;
}
}
View
@@ -13,17 +13,18 @@ class Panda::Fetcher does Pies::Fetcher {
method fetch (Pies::Project $p) {
my $dest = $!resources.workdir($p);
# the repo-* variants are kept for backwards compatibility only
- my $url = $p.metainfo<source-url> // $p.metainfo<repo-url>;
+ my $url = $p.metainfo<source-url> // $p.metainfo<repo-url>;
my $type = $p.metainfo<source-type> // $p.metainfo<repo-type>;
unless $type {
given $url {
- when /^git:/ {
+ when /^ [ 'git:' | 'http' 's'? '://github.com/' ] / {
$type = 'git';
}
default {
die $p, "Unable to determine source-type using source-url";
}
}
+ $p.metainfo<source-type> = $type;
}
given $type {
when 'git' {
@@ -36,6 +37,11 @@ class Panda::Fetcher does Pies::Fetcher {
shell "git clone -q $url $dest"
and die $p, "Failed cloning the repo";
}
+
+ indir $dest, {
+ my $desc = qx{git describe --always --dirty}.chomp;
+ $p.metainfo<source-revision> = $desc;
+ };
}
when 'local' {
for find(dir => $url).list {

0 comments on commit 506a8f7

Please sign in to comment.