diff options
author | Johan Sørensen <johan@johansorensen.com> | 2009-03-03 16:37:23 +0100 |
---|---|---|
committer | Johan Sørensen <johan@johansorensen.com> | 2009-04-22 15:15:41 +0200 |
commit | bc5edeff24c4ca232902dc7829bf85cbaeea11a4 (patch) | |
tree | 66d83a305d2881f830a01fb1e520d05eff1220e6 /app/controllers/blobs_controller.rb | |
parent | 3cea59d844481085df3f92074b4489f293e495aa (diff) | |
download | gitorious-mainline-outdated-bc5edeff24c4ca232902dc7829bf85cbaeea11a4.zip gitorious-mainline-outdated-bc5edeff24c4ca232902dc7829bf85cbaeea11a4.tar.gz gitorious-mainline-outdated-bc5edeff24c4ca232902dc7829bf85cbaeea11a4.tar.bz2 |
Redirect to the tree if no valid blob was found (in case users chop off the filename of the url)
Diffstat (limited to 'app/controllers/blobs_controller.rb')
-rw-r--r-- | app/controllers/blobs_controller.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/app/controllers/blobs_controller.rb b/app/controllers/blobs_controller.rb index a2ae61c..31c8784 100644 --- a/app/controllers/blobs_controller.rb +++ b/app/controllers/blobs_controller.rb @@ -30,13 +30,14 @@ class BlobsController < ApplicationController end if stale?(:etag => Digest::SHA1.hexdigest(@commit.id + params[:branch_and_path].join), :last_modified => @commit.committed_date.utc) @blob = @git.tree(@commit.tree.id, ["#{@path.join("/")}"]).contents.first + unless @blob.respond_to?(:data) # it's a tree + redirect_to repo_owner_path(@repository, :project_repository_tree_path, + @project, @repository, params[:branch_and_path]) + end head = @git.get_head(@ref) || Grit::Head.new(@commit.id_abbrev, @commit) @root = Breadcrumb::Blob.new(:paths => @path, :head => head, :repository => @repository, :name => @blob.basename) render_not_found and return unless @blob - unless @blob.respond_to?(:data) # it's a tree - redirect_to project_repository_tree_path(@project, @repository, @commit.id, @path) - end expires_in 2.minutes end end |