Check that git changeset is not in the database before creating it (#1419).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1953 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
5f9f6ea2e1
commit
8236563d6b
|
@ -45,20 +45,22 @@ class Repository::Git < Repository
|
||||||
|
|
||||||
unless changesets.find_by_scmid(scm_revision)
|
unless changesets.find_by_scmid(scm_revision)
|
||||||
scm.revisions('', db_revision, nil, :reverse => true) do |revision|
|
scm.revisions('', db_revision, nil, :reverse => true) do |revision|
|
||||||
transaction do
|
if changesets.find_by_scmid(revision.scmid.to_s).nil?
|
||||||
changeset = Changeset.create(:repository => self,
|
transaction do
|
||||||
:revision => revision.identifier,
|
changeset = Changeset.create!(:repository => self,
|
||||||
:scmid => revision.scmid,
|
:revision => revision.identifier,
|
||||||
:committer => revision.author,
|
:scmid => revision.scmid,
|
||||||
:committed_on => revision.time,
|
:committer => revision.author,
|
||||||
:comments => revision.message)
|
:committed_on => revision.time,
|
||||||
|
:comments => revision.message)
|
||||||
revision.paths.each do |change|
|
|
||||||
Change.create(:changeset => changeset,
|
revision.paths.each do |change|
|
||||||
:action => change[:action],
|
Change.create!(:changeset => changeset,
|
||||||
:path => change[:path],
|
:action => change[:action],
|
||||||
:from_path => change[:from_path],
|
:path => change[:path],
|
||||||
:from_revision => change[:from_revision])
|
:from_path => change[:from_path],
|
||||||
|
:from_revision => change[:from_revision])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,7 @@ class RepositoryGitTest < Test::Unit::TestCase
|
||||||
def test_fetch_changesets_incremental
|
def test_fetch_changesets_incremental
|
||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
# Remove the 3 latest changesets
|
# Remove the 3 latest changesets
|
||||||
@repository.changesets.find(:all, :order => 'id DESC', :limit => 3).each(&:destroy)
|
@repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy)
|
||||||
@repository.reload
|
@repository.reload
|
||||||
assert_equal 3, @repository.changesets.count
|
assert_equal 3, @repository.changesets.count
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue