2011-03-10 12:39:24 +00:00
|
|
|
class Git::BlobsController < Git::BaseController
|
|
|
|
before_filter :set_path
|
|
|
|
before_filter :set_commit_hash
|
2011-04-04 17:50:43 +01:00
|
|
|
before_filter :find_tree
|
2011-03-10 12:39:24 +00:00
|
|
|
|
|
|
|
def show
|
|
|
|
@blob = @tree / @path
|
|
|
|
end
|
|
|
|
|
|
|
|
def blame
|
|
|
|
@blob = @tree / @path
|
|
|
|
|
2011-03-11 17:19:47 +00:00
|
|
|
@blame = Grit::Blob.blame(@git_repository.repo, @commit.id, @path)
|
2011-03-10 12:39:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def raw
|
|
|
|
@blob = @tree / @path
|
|
|
|
|
|
|
|
headers["Content-Disposition"] = %[attachment;filename="#{@blob.name}"]
|
|
|
|
render :text => @blob.data, :content_type => @blob.mime_type
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
def set_path
|
2011-03-11 10:06:14 +00:00
|
|
|
@path = params[:path]
|
2011-03-10 12:39:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_commit_hash
|
|
|
|
@commit_hash = params[:commit_hash].present? ? params[:commit_hash] : nil
|
|
|
|
end
|
2011-04-04 17:50:43 +01:00
|
|
|
|
|
|
|
def find_tree
|
|
|
|
if @commit_hash
|
|
|
|
@tree = @git_repository.tree(@commit_hash)
|
|
|
|
@commit = @git_repository.commits(@treeish, 1).first
|
|
|
|
else
|
|
|
|
@tree = @git_repository.tree(@treeish)
|
|
|
|
|
|
|
|
@commit = @git_repository.log(@treeish, @path).first
|
|
|
|
@commit_hash = @commit.id if @commit
|
|
|
|
end
|
|
|
|
end
|
2011-03-10 12:39:24 +00:00
|
|
|
end
|