Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Exception on render with empty repository #291

Closed
rikvdh opened this Issue · 5 comments

4 participants

@rikvdh

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

+1

@klaussilveira

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

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

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

@NateEag

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
Something went wrong with that request. Please try again.