Permalink
Browse files

Combine eval names sharing prefix & rev

  • Loading branch information...
softmoth committed Apr 18, 2014
1 parent 2e98e16 commit 1a8a83e55d1572235885d2cbc0c904bfc31f02ce
Showing with 27 additions and 3 deletions.
  1. +27 −3 evalbot.pl
View
@@ -188,6 +188,30 @@ package Evalbot;
}
# warn "Regex: ", $regex, "\n";
sub format_names {
my ($names) = @_;
# Goal: rakudo-{jvm,moar} abcde, rakudo-parrot xyzzy, foo-other
my %by_rev;
foreach (@$names) {
my ($name, $rev) = @$_;
my ($prefix, $suffix) = ($name, '');
$name =~ /^(.+?-)(.+)$/
and ($prefix, $suffix) = ($1, $2);
push @{$by_rev{$rev}{$prefix}}, $suffix;
}
my @combined;
foreach my $r (sort keys %by_rev) {
foreach $p (sort keys %{$by_rev{$r}}) {
my $s = $by_rev{$r}{$p};
$s = @$s > 1
? '{' . join(',', @$s) . '}'
: $s->[0];
push @combined, $p . $s . ($r ? " $r" : '');
}
}
return join(', ', @combined);
}
sub said {
my $self = shift;
my $info = shift;
@@ -210,13 +234,13 @@ package Evalbot;
$tmp_res =~ s|/tmp/\w{10}|/tmp/tmpfile|g;
my $revision = '';
if (reftype($e) eq 'HASH' && $e->{revision}){
$revision = ' ' . $e->{revision}->();
$revision = $e->{revision}->();
}
push @{$results{$tmp_res}}, "$eval_name$revision";
push @{$results{$tmp_res}}, [$eval_name, $revision];
}
my $result = '';
while (my ($text, $names) = each %results){
$result .= format_output(join(', ', @$names), $text);
$result .= format_output(format_names($names), $text);
}
return $result;
}

0 comments on commit 1a8a83e

Please sign in to comment.