summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2014-07-07 15:46:57 +0200
committerMarin Jankovski <marin@gitlab.com>2014-07-07 15:46:57 +0200
commit005752e4c6485cf79b0a53583c03b5a69fe19f10 (patch)
treee940d94f5b5b0ba628794855414a4ec9015722a2 /app/controllers
parent5a67d482afd7780506c0dc2689a7d839647d5da5 (diff)
downloadgitlab-ce-005752e4c6485cf79b0a53583c03b5a69fe19f10.tar.gz
Check if blob or tree and redirect to the correct one.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/blob_controller.rb10
-rw-r--r--app/controllers/projects/tree_controller.rb9
2 files changed, 15 insertions, 4 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index a1a8bed09f4..db3d173b98d 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -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
diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb
index 30c94ec6da0..4d033b36848 100644
--- a/app/controllers/projects/tree_controller.rb
+++ b/app/controllers/projects/tree_controller.rb
@@ -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