diff options
author | Johan Sørensen <johan@johansorensen.com> | 2009-01-29 15:52:47 +0100 |
---|---|---|
committer | Johan Sørensen <johan@johansorensen.com> | 2009-04-22 12:55:16 +0200 |
commit | 9264b18931a78f6e0c1b9051470304d54f9d7b23 (patch) | |
tree | f536262158b75cc053acb90fb9267d17ec650713 /app/controllers/blobs_controller.rb | |
parent | ade00c90d629002dd0111a2a23d18f05790c2d12 (diff) | |
download | gitorious-mainline-outdated-9264b18931a78f6e0c1b9051470304d54f9d7b23.zip gitorious-mainline-outdated-9264b18931a78f6e0c1b9051470304d54f9d7b23.tar.gz gitorious-mainline-outdated-9264b18931a78f6e0c1b9051470304d54f9d7b23.tar.bz2 |
- Merged the logscontroller into a more unified commits controller
- Support namespaced branches with an uri alá /tree/branch/subbranch/path/in/repo
Diffstat (limited to 'app/controllers/blobs_controller.rb')
-rw-r--r-- | app/controllers/blobs_controller.rb | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/app/controllers/blobs_controller.rb b/app/controllers/blobs_controller.rb index 0615c1c..6a29827 100644 --- a/app/controllers/blobs_controller.rb +++ b/app/controllers/blobs_controller.rb @@ -18,31 +18,33 @@ class BlobsController < ApplicationController before_filter :find_project_and_repository before_filter :check_repository_for_commits - def show @git = @repository.git - @commit = @git.commit(params[:id]) + @ref, @path = branch_and_path(params[:branch_and_path], @git) + @commit = @git.commit(@ref) unless @commit - redirect_to project_repository_blob_path(@project, @repository, "HEAD", params[:path]) - return + redirect_to project_repository_blob_path(@project, @repository, + branch_with_tree("HEAD", @path)) and return end - @blob = @git.tree(@commit.tree.id, ["#{params[:path].join("/")}"]).contents.first - @root = Breadcrumb::Blob.new(:paths => params[:path], :head => @git.head, :repository => @repository, :name => @blob.basename) + @blob = @git.tree(@commit.tree.id, ["#{@path.join("/")}"]).contents.first + @root = Breadcrumb::Blob.new(:paths => @path, :head => @git.get_head(@ref), + :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, params[:path]) + redirect_to project_repository_tree_path(@project, @repository, @commit.id, @path) end end def raw @git = @repository.git - @commit = @git.commit(params[:id]) + @ref, @path = branch_and_path(params[:branch_and_path], @git) + @commit = @git.commit(@ref) unless @commit - redirect_to project_repository_raw_blob_path(@project, @repository, "HEAD", params[:path]) - return + redirect_to project_repository_raw_blob_path(@project, @repository, + branch_with_tree("HEAD", @path)) and return end - @blob = @git.tree(@commit.tree.id, ["#{params[:path].join("/")}"]).contents.first + @blob = @git.tree(@commit.tree.id, ["#{@path.join("/")}"]).contents.first render_not_found and return unless @blob if @blob.size > 500.kilobytes flash[:error] = I18n.t "blogs_controller.raw_error" |