From 9d2c9ae2b31e05be09585835944a0256ff5d68cf Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 20 Sep 2012 00:38:40 +0400 Subject: [PATCH] #385: added rsa to name of archives for git branches --- app/controllers/projects/git/base_controller.rb | 6 +++++- app/controllers/projects/git/trees_controller.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects/git/base_controller.rb b/app/controllers/projects/git/base_controller.rb index 60dd9792b..b4cef4810 100644 --- a/app/controllers/projects/git/base_controller.rb +++ b/app/controllers/projects/git/base_controller.rb @@ -12,7 +12,7 @@ class Projects::Git::BaseController < Projects::BaseController def set_treeish_and_path @treeish = params[:treeish].presence unless @treeish - commit = @project.repo.commits(@project.default_branch).first + commit = @project.repo.commits(@project.default_branch, 1).first @treeish = commit ? commit.id : @project.default_branch end @path = params[:path] @@ -21,6 +21,10 @@ class Projects::Git::BaseController < Projects::BaseController def set_branch_and_tree @branch = @project.repo.branches.detect{|b| b.name == @treeish} @tree = @project.repo.tree(@treeish) + if @branch + commit = @project.repo.commits(@treeish, 1).first + @treeish = commit.id if commit + end # raise Grit::NoSuchPathError if @tree.blobs.blank? end end diff --git a/app/controllers/projects/git/trees_controller.rb b/app/controllers/projects/git/trees_controller.rb index c133dfa3b..fd7696e97 100644 --- a/app/controllers/projects/git/trees_controller.rb +++ b/app/controllers/projects/git/trees_controller.rb @@ -14,7 +14,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController format = params[:format] if (@treeish =~ /^#{@project.owner.uname}-#{@project.name}-/) && !(@treeish =~ /[\s]+/) && (format =~ /^[\w]+$/) @treeish = @treeish.gsub(/^#{@project.owner.uname}-#{@project.name}-/, '') - @commit = @project.repo.log(@treeish, nil, :max_count => 1).first + @commit = @project.repo.commits(@treeish, 1).first end raise Grit::NoSuchPathError unless @commit name = "#{@project.owner.uname}-#{@project.name}-#{@treeish}"