From f92fcb669859ae4a00ef0ba9827f889d80c5197b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 22 Feb 2011 19:13:58 +0000 Subject: Create a new repo for the first time, even if reuse_repo is true --- lib/jitterbug/Builder.pm | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index dfb3f99..1e71e2e 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -103,23 +103,28 @@ sub run_task { $conf->{'jitterbug'}{'build'}{'dir'}, $task->project->name, ); - my ($r, $repo); + my $r; + my $repo = $task->project->url . '.git'; unless ($buildconf->{reuse_repo}) { debug("Removing $build_dir"); rmtree($build_dir, { error => \my $err } ); warn @$err if @$err; - $repo = $task->project->url . '.git'; $r = Git::Repository->create( clone => $repo => $build_dir ); } else { - 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"); - chdir $pwd; - $r = Git::Repository->new( work_tree => $build_dir ); + # If this is the first time, the repo won't exist yet + if( -e $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"); + chdir $pwd; + $r = Git::Repository->new( work_tree => $build_dir ); + } else { + $r = Git::Repository->create( clone => $repo => $build_dir ); + } } $self->sleep(1); # avoid race conditions -- cgit 1.4.1