Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve error handling and sanity checking in 'extract' command
  • Loading branch information
Geoffrey Broadwell committed Nov 19, 2012
1 parent 45eee9e commit ccf9079
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions bench
Expand Up @@ -87,33 +87,46 @@ multi MAIN ('extract', *@components) {
next;
}

# Find all tags known in this component
%*ENV<GIT_DIR> = $bare;
my $tag-list = open 'git tag', :p;
my @all-tags = $tag-list.lines;
$tag-list.close;
%*ENV.delete('GIT_DIR');

my @tags;
if $comp<checkouts> {
@tags = @($comp<checkouts>);
# User specified list of tags to extract
for $comp<checkouts>.list {
when any(@all-tags) { push @tags, $_ }
default { $*ERR.say: "No such tag '$_'" }
}
}
else {
# Determine which release tags to check out by default
# Check out filtered tag list by default
my $tag_regex = $comp<info><release_tags>;
next unless $tag_regex;

%*ENV<GIT_DIR> = $bare;
my $tag_list = open 'git tag', :p;
@tags = grep / <{ $tag_regex }> /, $tag_list.lines;
%*ENV.delete('GIT_DIR');
@tags = grep / <{ $tag_regex }> /, $tag-list.lines;
}

# Work around Rakudo bug #115390 by splitting into two loops
for @tags -> $tag {
next if $tag.IO.d;
if $tag.IO.d {
say "$tag already cloned.";
next;
}
run < git clone -l >, $bare, $tag;
}
for @tags -> $tag {
unless $tag.IO.d {
$*ERR.say: "Unable to extract release '$tag'.";
next;
}
chdir $tag; LEAVE chdir '..';
run < git checkout -q >, $tag; # > -- Dang syntax highlighting
}
}

say 'Extraction complete.';
}

#= Build checked out component trees
Expand Down

0 comments on commit ccf9079

Please sign in to comment.