From f2ed24ef8cbdb23153c551b5ec013571352c21e4 Mon Sep 17 00:00:00 2001 From: rick Date: Tue, 12 Oct 2010 10:02:48 -0700 Subject: [PATCH] extract multi_commit! method from GitAccess --- lib/gollum/git_access.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/gollum/git_access.rb b/lib/gollum/git_access.rb index ed5a7b59..25bace47 100644 --- a/lib/gollum/git_access.rb +++ b/lib/gollum/git_access.rb @@ -75,14 +75,18 @@ module Gollum missing_shas = shas.select do |sha| !cached_commits.key?(sha) end - if !missing_shas.empty? - missing_shas.each_slice(500) do |slice| - @repo.batch(slice).each do |commit| - cached_commits[commit.id] = commit - end + + multi_commit!(missing_shas, cached_commits) if !missing_shas.empty? + + shas.map { |sha| cached_commits[sha] } + end + + def multi_commit!(shas, hash) + shas.each_slice(500) do |slice| + @repo.batch(slice).each do |commit| + hash[commit.id] = commit end end - shas.map { |sha| cached_commits[sha] } end def sha?(str)