Skip to content
Snippets Groups Projects
Commit 005752e4 authored by Marin Jankovski's avatar Marin Jankovski
Browse files

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

parent 5a67d482
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
# 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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment