From: Toshi MARUYAMA Date: Mon, 28 Feb 2011 04:46:42 +0000 (+0000) Subject: scm: git: move saving changesets from adapter to model (#3396). X-Git-Tag: 1.2.0~864 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d7aa303a5ca01f5845f014f603d48bd98c56133c;p=redmine.git scm: git: move saving changesets from adapter to model (#3396). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4959 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb index 8fb6325b0..0ebd8668e 100644 --- a/app/models/repository/git.rb +++ b/app/models/repository/git.rb @@ -79,7 +79,28 @@ class Repository::Git < Repository revisions.reject!{|r| recent_revisions.include?(r.scmid)} # Save the remaining ones to the database - revisions.each{|r| r.save(self)} unless revisions.nil? + unless revisions.nil? + revisions.each do |rev| + transaction do + changeset = Changeset.new( + :repository => self, + :revision => rev.identifier, + :scmid => rev.scmid, + :committer => rev.author, + :committed_on => rev.time, + :comments => rev.message) + + if changeset.save + rev.paths.each do |file| + Change.create( + :changeset => changeset, + :action => file[:action], + :path => file[:path]) + end + end + end + end + end end def latest_changesets(path,rev,limit=10) diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 3f9bc0ef1..039513aa9 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -324,27 +324,6 @@ module Redmine def format_identifier identifier end - - def save(repo) - Changeset.transaction do - changeset = Changeset.new( - :repository => repo, - :revision => identifier, - :scmid => scmid, - :committer => author, - :committed_on => time, - :comments => message) - - if changeset.save - paths.each do |file| - Change.create( - :changeset => changeset, - :action => file[:action], - :path => file[:path]) - end - end - end - end end class Annotate