Check if blob or tree and redirect to the correct one.

This commit is contained in:
Marin Jankovski 2014-07-07 15:46:57 +02:00
parent 5a67d482af
commit 005752e4c6
2 changed files with 15 additions and 4 deletions

View file

@ -30,8 +30,12 @@ class Projects::BlobController < Projects::ApplicationController
def blob
@blob ||= @repository.blob_at(@commit.id, @path)
return not_found! unless @blob
@blob
if @blob
@blob
elsif tree.entries.any?
redirect_to project_tree_path(@project, File.join(@ref, @path)) and return
else
return not_found!
end
end
end

View file

@ -1,7 +1,14 @@
# Controller for viewing a repository's file structure
class Projects::TreeController < Projects::BaseTreeController
def show
return not_found! if tree.entries.empty?
if tree.entries.empty?
if @repository.blob_at(@commit.id, @path)
redirect_to project_blob_path(@project, File.join(@ref, @path)) and return
else
return not_found!
end
end
respond_to do |format|
format.html