scm: git: refactor saving a revision in model.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5624 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
cd34602b4f
commit
19c6266a7d
|
@ -98,27 +98,32 @@ class Repository::Git < Repository
|
|||
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
|
||||
save_revision(rev)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def save_revision(rev)
|
||||
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
|
||||
private :save_revision
|
||||
|
||||
def latest_changesets(path,rev,limit=10)
|
||||
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
|
||||
return [] if revisions.nil? || revisions.empty?
|
||||
|
|
Loading…
Reference in New Issue