2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-03-10 12:39:24 +00:00
|
|
|
class Git::TreesController < Git::BaseController
|
|
|
|
|
|
|
|
def show
|
2012-02-21 15:41:16 +00:00
|
|
|
if params[:treeish].present? and @treeish.dup.encode_to_default == @project.default_branch
|
|
|
|
redirect_to project_path(@project) and return
|
|
|
|
end
|
|
|
|
|
2011-03-10 12:39:24 +00:00
|
|
|
@path = params[:path]
|
|
|
|
|
2011-03-11 17:19:47 +00:00
|
|
|
@tree = @git_repository.tree(@treeish)
|
2012-02-21 15:41:16 +00:00
|
|
|
@branch = @project.branch(@treeish)
|
2011-04-04 12:28:33 +01:00
|
|
|
|
2011-04-07 14:20:21 +01:00
|
|
|
# @commit = @git_repository.commits(@treeish, 1).first
|
2011-04-04 14:49:08 +01:00
|
|
|
# Raises Grit::Git::GitTimeout
|
2012-02-21 15:41:16 +00:00
|
|
|
@commit = @branch.present? ? @branch.commit() : @git_repository.log(@treeish, @path, :max_count => 1).first
|
2012-03-01 22:23:53 +00:00
|
|
|
render :template => "git/repositories/empty" and return unless @commit
|
2011-03-11 10:06:14 +00:00
|
|
|
|
2012-02-21 15:41:16 +00:00
|
|
|
if @path
|
|
|
|
@path.force_encoding(Encoding::ASCII_8BIT)
|
|
|
|
@tree = @tree / @path
|
|
|
|
end
|
2011-03-10 12:39:24 +00:00
|
|
|
|
2011-03-10 13:19:23 +00:00
|
|
|
render :template => "git/repositories/show"
|
2011-03-10 12:39:24 +00:00
|
|
|
end
|
2012-01-30 20:39:34 +00:00
|
|
|
end
|