Hi,

I recently discoverd a problem with gitorious when I created a
repository called "users".

This leads to gitorious creating the repository but when this is
completetd and I am redirected to repository's website I get this
error:

Sorry, page not found
The page you were looking for does not exist. You may have mistyped,
or the page could be moved.

I encountered this on a private installation but the same happens at
gitorious.org

The same hold true for repository names such as "groups" and probably
all table names in the gitorious DB. Only a repository "repositories"
doesn't result in a "page not found" message, since
https://gitorious/projectname/repositories is already a reserved route
displaying all repos in that project. Nonetheless it is not possible
to edit the repository.

Possible mitigation: Check repository names before creating them and
if they match any of the reserved words (table names, routes) and
notify the user that he/she should choose a different name for the
repository. Maybe projects are also affected, but I do not want to try
to create a project with a title like "users" because it already took
me quite some time to figure out how to clean up after creating only a
repository with that name.

It is not possible to delete such repositories through the web
interface (well, besides deleting the entire project, which might not
be an option sometimes).

I am not a huge rails pro in any way but I managed to delete the
repository via the rails console, but this is where my trouble
started, because then my dashboard could not be viewed since "users"
was in my favorites list, thus one of my favorites was now nil.
Therefore I got this error via mail:

A ActionView::TemplateError occurred in site#index:

  undefined method `user' for nil:NilClass
  On line #131 of app/views/site/dashboard.html.erb

    128:       </div>
    129:       <ul class="with_icons">
    130:         <% @favorites.each do |favorite| %>
    131:           <li class="<%= css_classes_for(favorite) -%>">
    132:             <%= link_to_watchable(favorite) -%>
    133:           </li>
    134:         <% end %>

I managed to solve this by deleting the repo from my favorites list.
However it was also necessary to remove other references to that
repository. In my case, the repository was owned by a group/team, thus
trying to open the homepage of that team also resulted in a Page Not
Found. This results in an error like this:

A NoMethodError occurred in groups#show:

  undefined method `project_id' for nil:NilClass
  [RAILS_ROOT]/app/models/group.rb:85:in `all_related_project_ids'

Here is a short howto for getting rid of the "evil" repository:

1. Login to your gitorious instance
2. Switch user to the one owning gitorious, in my case git: sudo su
git
3. Switch to the directory where the gitorious code is: git@gitorious:
cd ~/gitorious/current
4. Start the rails console: RAILS_ENV=production /usr/local/bin/
gitorious_ruby script/console
5. evil = Repository.find_by_name "users" (note the repository id for
evil, you might need it later)
6. evil.delete
7. a = event.last
8. a.delete
9. g = Group.find_by_name "groupname"
10. If the evil repository is the newest for that group:
g.committerships = g.committerships - [g.committerships[-1]]
11. g.repository_ids = g.repository_ids - [ (repo id of evil
repository) ]
12. g.save
13. p = Project.find_by_title "affected_proj"
14. p.repository_ids = g.repository_ids - [ (repo id of evil
repository) ]
15. p.save

This should be it.

-- 
To post to this group, send email to gitorious@googlegroups.com
To unsubscribe from this group, send email to
gitorious+unsubscr...@googlegroups.com

Reply via email to