summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-09 06:19:18 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-09 06:19:18 +0000
commit22995fc9324774ce5301589d05a4687793faddac (patch)
tree014cecf3effce4fa04ab3119bf9186846dbf51c1 /app/controllers
parent4c3785afbf24b39a8574311b9ba36edbc6e26bc2 (diff)
parente87f2380779871a64742acdd9dd0358aac7eafce (diff)
downloadgitlab-ce-22995fc9324774ce5301589d05a4687793faddac.tar.gz
Merge branch 'redirect_betwee_tree_and_blob' into 'master'
Redirect between tree and blob This checks if on requested non-existing tree path blob exists, redirects to blob path if the file exists, otherwise return not found. See #1369 See merge request !953
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