Commit 005752e4 authored by Marin Jankovski's avatar Marin Jankovski

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

parent 5a67d482
...@@ -30,8 +30,12 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -30,8 +30,12 @@ class Projects::BlobController < Projects::ApplicationController
def blob def blob
@blob ||= @repository.blob_at(@commit.id, @path) @blob ||= @repository.blob_at(@commit.id, @path)
return not_found! unless @blob if @blob
@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
end end
# Controller for viewing a repository's file structure # Controller for viewing a repository's file structure
class Projects::TreeController < Projects::BaseTreeController class Projects::TreeController < Projects::BaseTreeController
def show 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| respond_to do |format|
format.html format.html
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment