Commit a9d224d36db59446f944c29a10725a85ebda3c5d

Authored by gitlabhq
1 parent 4e063dea

issue #124

app/controllers/application_controller.rb
... ... @@ -61,4 +61,8 @@ class ApplicationController < ActionController::Base
61 61 def render_404
62 62 render :file => File.join(Rails.root, "public", "404"), :layout => false, :status => "404"
63 63 end
  64 +
  65 + def require_non_empty_project
  66 + redirect_to @project unless @project.repo_exists?
  67 + end
64 68 end
... ...
app/controllers/commits_controller.rb
... ... @@ -6,6 +6,7 @@ class CommitsController < ApplicationController
6 6 # Authorize
7 7 before_filter :add_project_abilities
8 8 before_filter :authorize_read_project!
  9 + before_filter :require_non_empty_project
9 10  
10 11 def index
11 12 load_refs # load @branch, @tag & @ref
... ...
app/controllers/projects_controller.rb
... ... @@ -6,6 +6,8 @@ class ProjectsController < ApplicationController
6 6 before_filter :authorize_read_project!, :except => [:index, :new, :create]
7 7 before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy]
8 8  
  9 + before_filter :require_non_empty_project, :only => [:blob, :tree]
  10 +
9 11 def index
10 12 @projects = current_user.projects.all
11 13 end
... ... @@ -48,7 +50,7 @@ class ProjectsController < ApplicationController
48 50 def update
49 51 respond_to do |format|
50 52 if project.update_attributes(params[:project])
51   - format.html { redirect_to project, notice: 'Project was successfully updated.' }
  53 + format.html { redirect_to project, :notice => 'Project was successfully updated.' }
52 54 format.js
53 55 else
54 56 format.html { render action: "edit" }
... ...