only initalise GPP when we have a project.
Zachary Stevens [Sun, 1 Nov 2009 22:05:11 +0000 (22:05 +0000)]
lib/Gitalist/Model/Git.pm

index 5c8d69c..973de0a 100644 (file)
@@ -25,15 +25,17 @@ sub build_per_context_instance {
   my ( $self, $c ) = @_;
 
   my $app = blessed($c) || $c;
-  my $model = Git::Repos->new(
-    project => ([$c->req->parameters->{p} || '/']->flatten)[0],
-    repo_dir => $app->config->{repo_dir}, # FIXME - Move to model config
-  );
+  my $model = Git::Repos->new( repo_dir => $app->config->{repo_dir} );
 
-  # This is fugly as fuck. Move Git::PurePerl construction into attribute builders..
-  (my $pd = $self->project_dir( $self->project )) =~ s{/\.git$}();
-  $model->gpp( Git::PurePerl->new(directory => $pd) );
+  if ($c->req->parameters->{p}) {
+      # A Project was passed in
+      my $project = ([$c->req->parameters->{p} || '/']->flatten)[0];
+      $model->project( $project );
 
+      # This is fugly as fu\ack. Move Git::PurePerl construction into attribute builders..
+      (my $pd = $model->project_dir($project)) =~ s{/\.git$}();
+      $model->gpp( Git::PurePerl->new(directory => $pd) );
+  }
   return $model;
 }