Commit a9d224d36db59446f944c29a10725a85ebda3c5d

Authored by gitlabhq
1 parent 4e063dea

issue #124

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