From 20ec075a12bd2e9ffd7b5db7a311bc667ce368f0 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 17:23:22 -0700 Subject: Remove dep on Git::Repository --- lib/jitterbug/Builder.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 1f9bd3d..bb2e7b1 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -10,7 +10,6 @@ use File::Path qw/rmtree/; use Path::Class; use Getopt::Long qw/:config no_ignore_case/; use File::Basename; -use Git::Repository; use jitterbug::Schema; use Cwd; #use Data::Dumper; @@ -110,7 +109,7 @@ sub run_task { debug("Removing $build_dir"); rmtree($build_dir, { error => \my $err } ); warn @$err if @$err; - $r = Git::Repository->create( clone => $repo => $build_dir ); + system("git clone $repo $build_dir"); } else { # If this is the first time, the repo won't exist yet debug("build_dir = $build_dir"); -- cgit v1.2.3 From 2340f08919962775cd28d9613cbd7f2665bda61b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 21:14:54 -0700 Subject: Mess around with test data --- lib/jitterbug/Builder.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index bb2e7b1..01f7075 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -104,7 +104,7 @@ sub run_task { my $build_dir = dir($dir, $project->name); my $r; - my $repo = $task->project->url . '.git'; + my $repo = $task->project->url; unless ($buildconf->{reuse_repo}) { debug("Removing $build_dir"); rmtree($build_dir, { error => \my $err } ); -- cgit v1.2.3 From fe1f2bfe923e5941b8b988684015b31cba3969ba Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 22:22:07 -0700 Subject: Silence noisy checkout output --- lib/jitterbug/Builder.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 01f7075..256d3d5 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -122,7 +122,9 @@ sub run_task { debug("Fetching new commits into $repo"); system("git fetch"); debug("Checking out correct commit"); - system("git checkout " . $task->commit->sha256 ); + + # TODO: this may fail on non-unixy systems + system("git checkout " . $task->commit->sha256 . " &>/dev/null" ); chdir $pwd; } else { debug("Creating new repo"); -- cgit v1.2.3 From f4127b1235b585b5d82082fcfd820b68479ceba4 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 23:01:33 -0700 Subject: Add a test to verify we get the expected sha1 --- lib/jitterbug/Builder.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 256d3d5..eb9f924 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -124,7 +124,7 @@ sub run_task { debug("Checking out correct commit"); # TODO: this may fail on non-unixy systems - system("git checkout " . $task->commit->sha256 . " &>/dev/null" ); + system("git checkout " . $task->commit->sha256 . "&>/dev/null" ); chdir $pwd; } else { debug("Creating new repo"); @@ -138,10 +138,11 @@ sub run_task { $self->sleep(1); # avoid race conditions debug("Checking out " . $task->commit->sha256 . " from $repo into $build_dir\n"); - # $r->run( 'checkout', $task->commit->sha256 ); my $pwd = getcwd; chdir $build_dir; - system("git checkout " . $task->commit->sha256 ); + + # TODO: this may fail on non-unixy systems + system("git checkout " . $task->commit->sha256 . "&>/dev/null"); chdir $pwd; my $builder = $conf->{'jitterbug'}{'projects'}{$project->name}{'builder'} -- cgit v1.2.3 From 8443ce457031e90025650264983ce06a18dfe645 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 16:48:33 -0700 Subject: Factor out git logic to separate function --- lib/jitterbug/Builder.pm | 51 ++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index eb9f924..a70e560 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -80,30 +80,9 @@ sub sleep { sleep $interval; } -sub run_task { - my ($self,$task) = @_; - - my $desc = JSON::decode_json( $task->commit->content ); - my $conf = $self->{'conf'}; - my $buildconf = $conf->{'jitterbug'}{'build_process'}; - my $project = $task->project; - - my $dt = DateTime->now(); - $task->update({started_when => $dt}); - $desc->{'build'}{'start_time'} = $dt->epoch; - debug("Build Start"); +sub _prepare_git_repo { + my ($self, $task, $buildconf, $build_dir) = @_; - my $report_path = dir( - $conf->{'jitterbug'}{'reports'}{'dir'}, - $project->name, - $task->commit->sha256, - ); - my $dir = $conf->{'jitterbug'}{'build'}{'dir'}; - mkdir $dir unless -d $dir; - - my $build_dir = dir($dir, $project->name); - - my $r; my $repo = $task->project->url; unless ($buildconf->{reuse_repo}) { debug("Removing $build_dir"); @@ -144,6 +123,32 @@ sub run_task { # TODO: this may fail on non-unixy systems system("git checkout " . $task->commit->sha256 . "&>/dev/null"); chdir $pwd; +} + +sub run_task { + my ($self,$task) = @_; + + my $desc = JSON::decode_json( $task->commit->content ); + my $conf = $self->{'conf'}; + my $buildconf = $conf->{'jitterbug'}{'build_process'}; + my $project = $task->project; + + my $dt = DateTime->now(); + $task->update({started_when => $dt}); + $desc->{'build'}{'start_time'} = $dt->epoch; + debug("Build Start"); + + my $report_path = dir( + $conf->{'jitterbug'}{'reports'}{'dir'}, + $project->name, + $task->commit->sha256, + ); + my $dir = $conf->{'jitterbug'}{'build'}{'dir'}; + mkdir $dir unless -d $dir; + + my $build_dir = dir($dir, $project->name); + + $self->_prepare_git_repo($task, $buildconf, $build_dir); my $builder = $conf->{'jitterbug'}{'projects'}{$project->name}{'builder'} || $conf->{'jitterbug'}{'build_process'}{'builder'}; -- cgit v1.2.3 From 998b3daae7921b677b72f9bc74646bea864ce25f Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 16:54:28 -0700 Subject: Factor out result parsing to another function --- lib/jitterbug/Builder.pm | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index a70e560..fe820c3 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -154,9 +154,7 @@ sub run_task { || $conf->{'jitterbug'}{'build_process'}{'builder'}; my $perlbrew = $conf->{'jitterbug'}{'options'}{'perlbrew'}; - my $email_on_pass = $conf->{'jitterbug'}{'options'}{'email_on_pass'}; - debug("email_on_pass = $email_on_pass"); debug("perlbrew = $perlbrew"); # If the project has custom builder variables, use those. Otherwise, use the global setting @@ -171,6 +169,23 @@ sub run_task { $desc->{'build'}{'end_time'} = time(); + $self->_parse_results($report_path, $conf, $task, $desc); + + $task->commit->update( { + content => JSON::encode_json($desc), + } ); + debug("Task completed for " . $task->commit->sha256 . "\n"); + + $task->delete(); + + debug("Task removed from " . $task->project->name . "\n"); +} + +sub _parse_results { + my ($self, $report_path, $conf, $task, $desc) = @_; + my $email_on_pass = $conf->{'jitterbug'}{'options'}{'email_on_pass'}; + debug("email_on_pass = $email_on_pass"); + my @versions = glob( $report_path . '/*' ); foreach my $version (@versions) { open my $fh, '<', $version; @@ -237,14 +252,4 @@ sub run_task { $desc->{'build'}{'version'}{$name} = $result; close $fh; } - - $task->commit->update( { - content => JSON::encode_json($desc), - } ); - debug("Task completed for " . $task->commit->sha256 . "\n"); - - $task->delete(); - - debug("Task removed from " . $task->project->name . "\n"); } - -- cgit v1.2.3 From 6a46d858d3485ac1100cde4b591dd1b578c9b5de Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 17:01:32 -0700 Subject: Factor out the actual build for each task into another function --- lib/jitterbug/Builder.pm | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index fe820c3..c69c675 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -125,24 +125,9 @@ sub _prepare_git_repo { chdir $pwd; } -sub run_task { - my ($self,$task) = @_; - - my $desc = JSON::decode_json( $task->commit->content ); - my $conf = $self->{'conf'}; +sub build_task { + my ($self, $conf, $project, $task, $report_path) = @_; my $buildconf = $conf->{'jitterbug'}{'build_process'}; - my $project = $task->project; - - my $dt = DateTime->now(); - $task->update({started_when => $dt}); - $desc->{'build'}{'start_time'} = $dt->epoch; - debug("Build Start"); - - my $report_path = dir( - $conf->{'jitterbug'}{'reports'}{'dir'}, - $project->name, - $task->commit->sha256, - ); my $dir = $conf->{'jitterbug'}{'build'}{'dir'}; mkdir $dir unless -d $dir; @@ -166,6 +151,26 @@ sub run_task { debug("Going to run builder : $builder_command"); my $res = `$builder_command`; debug($res); +} + +sub run_task { + my ($self,$task) = @_; + + my $desc = JSON::decode_json( $task->commit->content ); + my $conf = $self->{'conf'}; + my $project = $task->project; + my $report_path = dir( + $conf->{'jitterbug'}{'reports'}{'dir'}, + $project->name, + $task->commit->sha256, + ); + + my $dt = DateTime->now(); + $task->update({started_when => $dt}); + $desc->{'build'}{'start_time'} = $dt->epoch; + debug("Build Start"); + + $self->build_task($conf, $project, $task, $report_path); $desc->{'build'}{'end_time'} = time(); -- cgit v1.2.3 From a2984e576811a035b568b5ff95a436199ea5dfb5 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 17:23:59 -0700 Subject: Factor out repo cloning --- lib/jitterbug/Builder.pm | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index c69c675..c168a66 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -80,15 +80,28 @@ sub sleep { sleep $interval; } +sub _clone_into { + my ($repo, $dir) = @_; + my $pwd = getcwd; + chdir $dir; + + debug("cloning $repo into $dir"); + system("git clone $repo $dir"); + + chdir $pwd; +} + sub _prepare_git_repo { - my ($self, $task, $buildconf, $build_dir) = @_; + my ($self, $task, $buildconf, $build_dir, $cached_repo_dir) = @_; my $repo = $task->project->url; unless ($buildconf->{reuse_repo}) { debug("Removing $build_dir"); rmtree($build_dir, { error => \my $err } ); warn @$err if @$err; - system("git clone $repo $build_dir"); + + _clone_into($repo, $build_dir); + } else { # If this is the first time, the repo won't exist yet debug("build_dir = $build_dir"); @@ -106,12 +119,7 @@ sub _prepare_git_repo { system("git checkout " . $task->commit->sha256 . "&>/dev/null" ); chdir $pwd; } else { - debug("Creating new repo"); - my $pwd = getcwd; - debug("pwd=$pwd"); - chdir $build_dir; - system("git clone $repo $build_dir"); - chdir $pwd; + _clone_into($repo, $build_dir); } } $self->sleep(1); # avoid race conditions @@ -127,13 +135,18 @@ sub _prepare_git_repo { sub build_task { my ($self, $conf, $project, $task, $report_path) = @_; + my $buildconf = $conf->{'jitterbug'}{'build_process'}; - my $dir = $conf->{'jitterbug'}{'build'}{'dir'}; + my $dir = $conf->{'jitterbug'}{'build'}{'dir'}; + mkdir $dir unless -d $dir; my $build_dir = dir($dir, $project->name); + my $cached_repo_dir = dir($dir, 'cached'); + + mkdir $cached_repo_dir unless -d $cached_repo_dir; - $self->_prepare_git_repo($task, $buildconf, $build_dir); + $self->_prepare_git_repo($task, $buildconf, $build_dir, $cached_repo_dir); my $builder = $conf->{'jitterbug'}{'projects'}{$project->name}{'builder'} || $conf->{'jitterbug'}{'build_process'}{'builder'}; @@ -151,6 +164,7 @@ sub build_task { debug("Going to run builder : $builder_command"); my $res = `$builder_command`; debug($res); + return $res; } sub run_task { -- cgit v1.2.3 From 2e70da0107303e88428d7ac58773cb0a06b5d5c3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 17:45:35 -0700 Subject: Refactor _parse_results and enable debugging in the git tests --- lib/jitterbug/Builder.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index c168a66..33efea2 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -234,15 +234,15 @@ sub _parse_results { my $on_failure_cc_email = $conf->{'jitterbug'}{'build_process'}{'on_failure_cc_email'}; $message =~ s/'/\\'/g; $commiter =~ s/'/\\'/g; $output =~ s/'/\\'/g; - my $failure_cmd = sprintf("%s '%s' %s '%s' '%s' %s %s", $on_failure, $commiter, $task->project->name, $message, $output, $sha, $on_failure_cc_email); - debug("Running failure command: $failure_cmd"); - # does it look like a module name? if ($on_failure =~ /::/) { # we should do some error checking here eval "require $on_failure"; $on_failure->new($conf,$task,$output,'failure')->run; } else { + my $failure_cmd = sprintf("%s '%s' %s '%s' '%s' %s %s", $on_failure, $commiter, $task->project->name, $message, $output, $sha, $on_failure_cc_email); + debug("Running failure command: $failure_cmd"); + system($failure_cmd); } } elsif ($email_on_pass) { @@ -256,8 +256,6 @@ sub _parse_results { my $on_pass_cc_email = $conf->{'jitterbug'}{'build_process'}{'on_pass_cc_email'}; $message =~ s/'/\\'/g; $commiter =~ s/'/\\'/g; $output =~ s/'/\\'/g; - my $pass_cmd = sprintf("%s '%s' %s '%s' '%s' %s %s", $on_pass, $commiter, $task->project->name, $message, $output, $sha, $on_pass_cc_email); - debug("Running pass command: $pass_cmd"); # does it look like a module name? if ($on_pass =~ /::/) { @@ -265,6 +263,8 @@ sub _parse_results { eval "require $on_pass"; $on_pass->new($conf,$task,$output, 'pass')->run; } else { + my $pass_cmd = sprintf("%s '%s' %s '%s' '%s' %s %s", $on_pass, $commiter, $task->project->name, $message, $output, $sha, $on_pass_cc_email); + debug("Running pass command: $pass_cmd"); system($pass_cmd); } } -- cgit v1.2.3 From c113da97a61813d5684eebb966f6fb9b8b3efeca Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 18:07:14 -0700 Subject: Refactor and alter git repo caching strategy Our previous strategy occasionally failed if a build got the cached git repo into an odd state (such as leaving a git lockfile), so now we clone a new repo for every build from our local cached copy. The only operations performed in the cached repo is a git fetch --prune --- lib/jitterbug/Builder.pm | 63 ++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 33efea2..5befade 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -95,42 +95,47 @@ sub _prepare_git_repo { my ($self, $task, $buildconf, $build_dir, $cached_repo_dir) = @_; my $repo = $task->project->url; - unless ($buildconf->{reuse_repo}) { - debug("Removing $build_dir"); - rmtree($build_dir, { error => \my $err } ); - warn @$err if @$err; + my $name = $task->project->name; - _clone_into($repo, $build_dir); + debug("Removing $build_dir"); + rmtree($build_dir, { error => \my $err } ); + warn @$err if @$err; + # If we aren't reusing/caching git repos, clone from remote into the build dir + unless ($buildconf->{reuse_repo}) { + _clone_into($repo, $build_dir); } else { - # If this is the first time, the repo won't exist yet + # We are caching git repos, so we clone a new repo from our local + # cached git repo, then checkout the correct sha1 + debug("build_dir = $build_dir"); - if( -d $build_dir ){ - my $pwd = getcwd; - chdir $build_dir; - # TODO: Error Checking - debug("Cleaning git repo"); - system("git clean -dfx"); - debug("Fetching new commits into $repo"); - system("git fetch"); - debug("Checking out correct commit"); - - # TODO: this may fail on non-unixy systems - system("git checkout " . $task->commit->sha256 . "&>/dev/null" ); - chdir $pwd; - } else { - _clone_into($repo, $build_dir); + unless ( -d $cached_repo_dir ) { + # If this is the first time, the repo won't exist yet + # Clone it into our cached repo directory + _clone_into($repo, $cached_repo_dir); } - } - $self->sleep(1); # avoid race conditions + my $pwd = getcwd; - debug("Checking out " . $task->commit->sha256 . " from $repo into $build_dir\n"); - my $pwd = getcwd; - chdir $build_dir; + chdir $cached_repo_dir; + # TODO: Error Checking - # TODO: this may fail on non-unixy systems - system("git checkout " . $task->commit->sha256 . "&>/dev/null"); - chdir $pwd; + debug("Fetching new commits into $repo"); + system("git fetch --prune"); + chdir $pwd; + + debug("Cloning from cached repo $cached_repo_dir into $build_dir"); + + _clone_into($cached_repo_dir, $build_dir); + chdir $build_dir; + + $self->sleep(1); # avoid race conditions + + # TODO: this may fail on non-unixy systems + debug("checking out " . $task->commit->sha256); + system("git checkout " . $task->commit->sha256 . "&>/dev/null" ); + + chdir $pwd; + } } sub build_task { -- cgit v1.2.3 From 915a1b86928015892b76156e5702a9a8032ce854 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 18:31:28 -0700 Subject: Attempt to fix cloning --- lib/jitterbug/Builder.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 5befade..7a06ecb 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -109,7 +109,7 @@ sub _prepare_git_repo { # cached git repo, then checkout the correct sha1 debug("build_dir = $build_dir"); - unless ( -d $cached_repo_dir ) { + unless ( -d catfile($cached_repo_dir,$name) ) { # If this is the first time, the repo won't exist yet # Clone it into our cached repo directory _clone_into($repo, $cached_repo_dir); @@ -119,7 +119,7 @@ sub _prepare_git_repo { chdir $cached_repo_dir; # TODO: Error Checking - debug("Fetching new commits into $repo"); + debug("Fetching new commits into $cached_repo_dir"); system("git fetch --prune"); chdir $pwd; -- cgit v1.2.3 From af2884967461e009186382329dcfd11c9d436c61 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 18:35:30 -0700 Subject: Import catfile --- lib/jitterbug/Builder.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 7a06ecb..0413e4d 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -10,6 +10,7 @@ use File::Path qw/rmtree/; use Path::Class; use Getopt::Long qw/:config no_ignore_case/; use File::Basename; +use File::Spec::Functions; use jitterbug::Schema; use Cwd; #use Data::Dumper; -- cgit v1.2.3 From 25b912d55512f28cd7d839957df0d576a68bb6ea Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 18:53:11 -0700 Subject: Attempt to fix cloning again --- lib/jitterbug/Builder.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 0413e4d..1f66343 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -113,7 +113,7 @@ sub _prepare_git_repo { unless ( -d catfile($cached_repo_dir,$name) ) { # If this is the first time, the repo won't exist yet # Clone it into our cached repo directory - _clone_into($repo, $cached_repo_dir); + _clone_into($repo, catfile($cached_repo_dir, $name)); } my $pwd = getcwd; -- cgit v1.2.3 From 6db7e1a4e8e1689514171eeb0863e915e96ed508 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 19:21:36 -0700 Subject: Make sure the cached repo dir exists and clone from the correct cached dir --- lib/jitterbug/Builder.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 1f66343..6f882b4 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -110,6 +110,8 @@ sub _prepare_git_repo { # cached git repo, then checkout the correct sha1 debug("build_dir = $build_dir"); + mkdir $cached_repo_dir unless -d $cached_repo_dir; + unless ( -d catfile($cached_repo_dir,$name) ) { # If this is the first time, the repo won't exist yet # Clone it into our cached repo directory @@ -124,9 +126,9 @@ sub _prepare_git_repo { system("git fetch --prune"); chdir $pwd; - debug("Cloning from cached repo $cached_repo_dir into $build_dir"); + debug("Cloning from cached repo $cached_repo_dir/$name into $build_dir"); - _clone_into($cached_repo_dir, $build_dir); + _clone_into(catdir($cached_repo_dir,$name), $build_dir); chdir $build_dir; $self->sleep(1); # avoid race conditions -- cgit v1.2.3 From 6b15ad18f2297bd195a3878ce6170de53db20ce5 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 19:31:04 -0700 Subject: Call git fetch from the correct directory --- lib/jitterbug/Builder.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 6f882b4..0eeab30 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -111,23 +111,24 @@ sub _prepare_git_repo { debug("build_dir = $build_dir"); mkdir $cached_repo_dir unless -d $cached_repo_dir; + my $cached_repo = catfile($cached_repo_dir,$name) ); - unless ( -d catfile($cached_repo_dir,$name) ) { + unless ( -d $cached_repo ) { # If this is the first time, the repo won't exist yet # Clone it into our cached repo directory - _clone_into($repo, catfile($cached_repo_dir, $name)); + _clone_into($repo, $cached_repo); } my $pwd = getcwd; - chdir $cached_repo_dir; + chdir $cached_repo; # TODO: Error Checking - debug("Fetching new commits into $cached_repo_dir"); + debug("Fetching new commits into $cached_repo"); system("git fetch --prune"); - chdir $pwd; - debug("Cloning from cached repo $cached_repo_dir/$name into $build_dir"); + $self->sleep(1); # avoid race conditions + debug("Cloning from cached repo $cached_repo_dir/$name into $build_dir"); _clone_into(catdir($cached_repo_dir,$name), $build_dir); chdir $build_dir; -- cgit v1.2.3 From 66d50b4d29b2656005c8b46f6222ccdb1a802c72 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 19:32:54 -0700 Subject: Fix syntax error --- lib/jitterbug/Builder.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 0eeab30..ab96251 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -111,7 +111,7 @@ sub _prepare_git_repo { debug("build_dir = $build_dir"); mkdir $cached_repo_dir unless -d $cached_repo_dir; - my $cached_repo = catfile($cached_repo_dir,$name) ); + my $cached_repo = catfile($cached_repo_dir,$name); unless ( -d $cached_repo ) { # If this is the first time, the repo won't exist yet -- cgit v1.2.3