Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor handling of COMPONENTS_DIR and checking whether setup has be…
…en done
  • Loading branch information
Geoffrey Broadwell committed Oct 21, 2012
1 parent 91def7b commit f6ce8a9
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions bench
Expand Up @@ -10,6 +10,8 @@ use JSON::Tiny;
my ($PROGRAM_DIR) = ~($*PROGRAM_NAME ~~ /^(.*\/)/) // './';
chdir $PROGRAM_DIR;
$PROGRAM_DIR = cwd;
my $COMPONENTS_DIR = "$PROGRAM_DIR/components";


#= Show benchmark configuration
multi MAIN ('config') {
Expand All @@ -28,14 +30,11 @@ multi MAIN ('setup') {
my $components = from-json(slurp 'components.json');

say 'Cloning component repos ...';
chdir 'components';
my $comp_dir = cwd;

for $components.values -> $component {
my $name = $component<name>;
say "==> $name";

chdir $comp_dir;
chdir $COMPONENTS_DIR;
mkdir $name unless $name.IO.d;
chdir $name;

Expand All @@ -50,19 +49,14 @@ multi MAIN ('setup') {

#= Fetch latest commits in each cloned component
multi MAIN ('fetch') {
unless 'components'.IO.d {
say "There is no 'components' tree, and thus there are no repos to fetch.";
say "Please run `$*PROGRAM_NAME setup` instead.";
return;
}
needs-setup('fetch');

chdir 'components';
my $comp_dir = cwd;
chdir $COMPONENTS_DIR;

for dir('.').sort -> $component-name {
say "==> $component-name";
my $bare = "$component-name/$component-name.git";

my $bare = "$component-name/$component-name.git";
unless $bare.IO.d {
say "No bare repository exists for component $component-name; can't fetch updates.";
next;
Expand All @@ -73,6 +67,14 @@ multi MAIN ('fetch') {
}
}

sub needs-setup ($action) {
unless $COMPONENTS_DIR.IO.d {
say "There is no 'components' tree, and thus there are no repos to $action.";
say "Please run `$*PROGRAM_NAME setup`.";
exit 1;
}
}

multi MAIN ('build') {
# %*ENV<GIT_DIR> = $bare;
# my $tag_list = open 'git tag', :p;
Expand Down

0 comments on commit f6ce8a9

Please sign in to comment.