extract multi_commit! method from GitAccess

This commit is contained in:
rick
2010-10-12 10:02:48 -07:00
parent c6dc4acc02
commit f2ed24ef8c
+11 -7
View File
@@ -75,16 +75,20 @@ module Gollum
missing_shas = shas.select do |sha| missing_shas = shas.select do |sha|
!cached_commits.key?(sha) !cached_commits.key?(sha)
end end
if !missing_shas.empty?
missing_shas.each_slice(500) do |slice| multi_commit!(missing_shas, cached_commits) if !missing_shas.empty?
@repo.batch(slice).each do |commit|
cached_commits[commit.id] = commit
end
end
end
shas.map { |sha| cached_commits[sha] } shas.map { |sha| cached_commits[sha] }
end end
def multi_commit!(shas, hash)
shas.each_slice(500) do |slice|
@repo.batch(slice).each do |commit|
hash[commit.id] = commit
end
end
end
def sha?(str) def sha?(str)
str =~ /^[0-9a-f]{40}$/ str =~ /^[0-9a-f]{40}$/
end end