Exception on render with empty repository #291

Closed
rikvdh opened this Issue Mar 17, 2013 · 5 comments

Comments

Projects
None yet
4 participants
@rikvdh

rikvdh commented Mar 17, 2013

Hi,

I get an exception when i try to open the index page when one of the repositories in my repo-directory is empty (freshly created with git --bare init).

Oops! An exception has been thrown during the rendering of a template ("Parameter "branch" for route "rss" must match "[\w-._/]+" ("" given) to generate a corresponding URL.") in "index.twig" at line 13.

When i create the master branch by committing something to the directory the issue does not appear anymore.

Greetings,

Rik

@Matan

This comment has been minimized.

Show comment Hide comment
@Matan

Matan Mar 25, 2013

+1

Matan commented Mar 25, 2013

+1

@klaussilveira

This comment has been minimized.

Show comment Hide comment
@klaussilveira

klaussilveira Mar 29, 2013

Owner

Currently, if it's null, we don't handle the situation properly. @NateEag, can you take a look at that code you submitted some time ago and see if you're able to support null branches?

Owner

klaussilveira commented Mar 29, 2013

Currently, if it's null, we don't handle the situation properly. @NateEag, can you take a look at that code you submitted some time ago and see if you're able to support null branches?

@NateEag

This comment has been minimized.

Show comment Hide comment
@NateEag

NateEag Mar 29, 2013

Contributor

I'll try to take a look. I assume we'd just want to display a basic "no commits yet" message if you try to view an empty repo?

Contributor

NateEag commented Mar 29, 2013

I'll try to take a look. I assume we'd just want to display a basic "no commits yet" message if you try to view an empty repo?

@klaussilveira

This comment has been minimized.

Show comment Hide comment
@klaussilveira

klaussilveira Mar 29, 2013

Owner

The problem is not exactly what to do (no files, no commits, etc, would be the best choice), but avoid routes from crashing.

Owner

klaussilveira commented Mar 29, 2013

The problem is not exactly what to do (no files, no commits, etc, would be the best choice), but avoid routes from crashing.

@NateEag

This comment has been minimized.

Show comment Hide comment
@NateEag

NateEag Mar 31, 2013

Contributor

Interestingly, when I first tried to reproduce this, I could not. I pulled current master and initialized a bare repo in my repos directory, and the index page just worked.

Once I updated my dependencies with Composer, however, the problem started happening.

This makes me wonder whether the issue may be lurking in one of GitList's dependencies, rather than in GitList itself, as the problem did not occur for me with older dependencies? Possibly some behavior change in Gitter? I've saved my previous composer.lock, to enable further research.

That said, a quick nasty hack that makes the index page work is:

diff --git a/views/index.twig b/views/index.twig
index b3f075d..5a7243b 100644
--- a/views/index.twig
+++ b/views/index.twig
@@ -10,7 +10,11 @@
     <div class="repository">
         <div class="repository-header">
             <i class="icon-folder-open icon-spaced"></i> <a href="{{ path('repo
+            {% if repository.branch is not none %}
             <a href="{{ path('rss', {repo: repository.relativePath, branch: rep
+            {% else %}
+            <span class="pull-right">No commits here. Start hacking!</span>
+            {% endif %}
         </div>
         <div class="repository-body">
             <p>{{ repository.description }}</p>

Not lovely, but better than totally broken.

I may not get a chance to look at this again for a little while, so if someone else has time, feel free to dig in.

Contributor

NateEag commented Mar 31, 2013

Interestingly, when I first tried to reproduce this, I could not. I pulled current master and initialized a bare repo in my repos directory, and the index page just worked.

Once I updated my dependencies with Composer, however, the problem started happening.

This makes me wonder whether the issue may be lurking in one of GitList's dependencies, rather than in GitList itself, as the problem did not occur for me with older dependencies? Possibly some behavior change in Gitter? I've saved my previous composer.lock, to enable further research.

That said, a quick nasty hack that makes the index page work is:

diff --git a/views/index.twig b/views/index.twig
index b3f075d..5a7243b 100644
--- a/views/index.twig
+++ b/views/index.twig
@@ -10,7 +10,11 @@
     <div class="repository">
         <div class="repository-header">
             <i class="icon-folder-open icon-spaced"></i> <a href="{{ path('repo
+            {% if repository.branch is not none %}
             <a href="{{ path('rss', {repo: repository.relativePath, branch: rep
+            {% else %}
+            <span class="pull-right">No commits here. Start hacking!</span>
+            {% endif %}
         </div>
         <div class="repository-body">
             <p>{{ repository.description }}</p>

Not lovely, but better than totally broken.

I may not get a chance to look at this again for a little while, so if someone else has time, feel free to dig in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment