scm: git: override adapter entry() for browsing tree performance (#7047).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5640 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-05-04 18:07:50 +00:00
parent 97b4ee2fef
commit 18df827244
1 changed files with 14 additions and 0 deletions

View File

@ -106,6 +106,20 @@ module Redmine
bras.include?('master') ? 'master' : bras.first
end
def entry(path=nil, identifier=nil)
parts = path.to_s.split(%r{[\/\\]}).select {|n| !n.blank?}
search_path = parts[0..-2].join('/')
search_name = parts[-1]
if search_path.blank? && search_name.blank?
# Root entry
Entry.new(:path => '', :kind => 'dir')
else
# Search for the entry in the parent directory
es = entries(search_path, identifier)
es ? es.detect {|e| e.name == search_name} : nil
end
end
def entries(path=nil, identifier=nil, options={})
entries_git(path, identifier, options)
end