summaryrefslogtreecommitdiffstats
path: root/app/models/repository
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-13 10:38:45 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-13 10:38:45 +0000
commit7ca5a4939e88723d38a634e32ca983cd15326e70 (patch)
treef0c93d0f98bea7a35e3e2418d9f5ae288e66f139 /app/models/repository
parentb0f5d3cd8846460bc17ec26f225081006ccd58ac (diff)
downloadredmine-7ca5a4939e88723d38a634e32ca983cd15326e70.tar.gz
redmine-7ca5a4939e88723d38a634e32ca983cd15326e70.zip
scm: git: fix fetching 7 days problem (#7146, #6013).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5788 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository')
-rw-r--r--app/models/repository/git.rb45
1 files changed, 16 insertions, 29 deletions
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index 51a2ca82d..3e2edd9f7 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -103,39 +103,26 @@ class Repository::Git < Repository
#
# But, Git 1.7.3.4 does not support --reverse with -n or --skip.
#
- # 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
- # it knows about.
- # However, with git, you never know if people have merged
- # commits into the middle of the repository history, so we should parse
- # the entire log.
- #
- # Since it's way too slow for large repositories,
- # we only parse 1 week before the last known commit.
- #
# The repository can still be fully reloaded by calling #clear_changesets
# before fetching changesets (eg. for offline resync)
def fetch_changesets
- c = changesets.find(:first, :order => 'committed_on DESC')
- since = (c ? c.committed_on - 7.days : nil)
-
- revisions = scm.revisions('', nil, nil, {:all => true, :since => since, :reverse => true})
- return if revisions.nil? || revisions.empty?
-
- recent_changesets = changesets.find(:all, :conditions => ['committed_on >= ?', since])
-
- # Clean out revisions that are no longer in git
- recent_changesets.each {|c| c.destroy unless revisions.detect {|r| r.scmid.to_s == c.scmid.to_s }}
-
- # Subtract revisions that redmine already knows about
- recent_revisions = recent_changesets.map{|c| c.scmid}
- revisions.reject!{|r| recent_revisions.include?(r.scmid)}
-
- # Save the remaining ones to the database
- unless revisions.nil?
- revisions.each do |rev|
+ scm_brs = branches
+ return if scm_brs.nil? || scm_brs.empty?
+ h = extra_info || {}
+ h["branches"] ||= {}
+ scm_brs.each do |br|
+ from_scmid = nil
+ from_scmid = h["branches"][br]["last_scmid"] if h["branches"][br]
+ h["branches"][br] ||= {}
+ scm.revisions('', from_scmid, br, {:reverse => true}) do |rev|
+ db_rev = find_changeset_by_name(rev.revision)
transaction do
- save_revision(rev)
+ if db_rev.nil?
+ save_revision(rev)
+ end
+ h["branches"][br]["last_scmid"] = rev.scmid
+ merge_extra_info(h)
+ self.save
end
end
end