Use the stashed project object for uri generation rather than the attribute in the...
[catagits/Gitalist.git] / lib / Gitalist.pm
index 0def39d..edd3519 100644 (file)
@@ -53,10 +53,13 @@ __PACKAGE__->setup();
 
 around uri_for => sub {
   my ($orig, $c) = (shift, shift);
+  my $project_name = $c->stash->{'Project'} && $c->stash->{'Project'}->name;
+  my $hash = ref($_[-1]) eq 'HASH' ? pop @_ : {};
   my $params = Catalyst::Utils::merge_hashes(
-    { p => $c->model('Git')->project },
-    ref($_[-1]) eq 'HASH' ? pop @_ : {}
+    { p => $hash->{p} || $project_name },
+    $hash,
   );
+  delete $params->{p} unless defined $params->{p} && length $params->{p};
   (my $uri = $c->$orig(@_, $params))
     =~ tr[&][;];
   return $uri;