Skip to content

Commit ccf9079

Browse files
author
Geoffrey Broadwell
committed
Improve error handling and sanity checking in 'extract' command
1 parent 45eee9e commit ccf9079

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

bench

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,33 +87,46 @@ multi MAIN ('extract', *@components) {
8787
next;
8888
}
8989

90+
# Find all tags known in this component
91+
%*ENV<GIT_DIR> = $bare;
92+
my $tag-list = open 'git tag', :p;
93+
my @all-tags = $tag-list.lines;
94+
$tag-list.close;
95+
%*ENV.delete('GIT_DIR');
96+
9097
my @tags;
9198
if $comp<checkouts> {
92-
@tags = @($comp<checkouts>);
99+
# User specified list of tags to extract
100+
for $comp<checkouts>.list {
101+
when any(@all-tags) { push @tags, $_ }
102+
default { $*ERR.say: "No such tag '$_'" }
103+
}
93104
}
94105
else {
95-
# Determine which release tags to check out by default
106+
# Check out filtered tag list by default
96107
my $tag_regex = $comp<info><release_tags>;
97108
next unless $tag_regex;
98109

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

105113
# Work around Rakudo bug #115390 by splitting into two loops
106114
for @tags -> $tag {
107-
next if $tag.IO.d;
115+
if $tag.IO.d {
116+
say "$tag already cloned.";
117+
next;
118+
}
108119
run < git clone -l >, $bare, $tag;
109120
}
110121
for @tags -> $tag {
122+
unless $tag.IO.d {
123+
$*ERR.say: "Unable to extract release '$tag'.";
124+
next;
125+
}
111126
chdir $tag; LEAVE chdir '..';
112127
run < git checkout -q >, $tag; # > -- Dang syntax highlighting
113128
}
114129
}
115-
116-
say 'Extraction complete.';
117130
}
118131

119132
#= Build checked out component trees

0 commit comments

Comments
 (0)