scm: git: implement find_changeset_by_name (#7047).

SQL "like" is slow.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4851 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-02-16 11:16:53 +00:00
parent 862058795f
commit 724afdf49d
1 changed files with 7 additions and 0 deletions

View File

@ -47,6 +47,13 @@ class Repository::Git < Repository
scm.tags scm.tags
end end
def find_changeset_by_name(name)
return nil if name.nil? || name.empty?
e = changesets.find(:first, :conditions => ['revision = ?', name.to_s])
return e if e
changesets.find(:first, :conditions => ['scmid LIKE ?', "#{name}%"])
end
# With SCM's that have a sequential commit numbering, redmine is able to be # With SCM's that have a sequential commit numbering, redmine is able to be
# clever and only fetch changesets going forward from the most recent one # clever and only fetch changesets going forward from the most recent one
# it knows about. However, with git, you never know if people have merged # it knows about. However, with git, you never know if people have merged