Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on render with empty repository #291

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

Exception on render with empty repository #291

rikvdh opened this issue Mar 17, 2013 · 5 comments

Comments

@rikvdh
Copy link

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
Copy link

Matan commented Mar 25, 2013

+1

@klaussilveira
Copy link
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?

@NateEag
Copy link
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
Copy link
Owner

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

@NateEag
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants