##// END OF EJS Templates
Check that git changeset is not in the database before creating it (#1419)....
Jean-Philippe Lang -
r1951:8236563d6bdc
parent child
Show More
@@ -45,20 +45,22 class Repository::Git < Repository
45 45
46 46 unless changesets.find_by_scmid(scm_revision)
47 47 scm.revisions('', db_revision, nil, :reverse => true) do |revision|
48 transaction do
49 changeset = Changeset.create(:repository => self,
50 :revision => revision.identifier,
51 :scmid => revision.scmid,
52 :committer => revision.author,
53 :committed_on => revision.time,
54 :comments => revision.message)
55
56 revision.paths.each do |change|
57 Change.create(:changeset => changeset,
58 :action => change[:action],
59 :path => change[:path],
60 :from_path => change[:from_path],
61 :from_revision => change[:from_revision])
48 if changesets.find_by_scmid(revision.scmid.to_s).nil?
49 transaction do
50 changeset = Changeset.create!(:repository => self,
51 :revision => revision.identifier,
52 :scmid => revision.scmid,
53 :committer => revision.author,
54 :committed_on => revision.time,
55 :comments => revision.message)
56
57 revision.paths.each do |change|
58 Change.create!(:changeset => changeset,
59 :action => change[:action],
60 :path => change[:path],
61 :from_path => change[:from_path],
62 :from_revision => change[:from_revision])
63 end
62 64 end
63 65 end
64 66 end
@@ -42,7 +42,7 class RepositoryGitTest < Test::Unit::TestCase
42 42 def test_fetch_changesets_incremental
43 43 @repository.fetch_changesets
44 44 # Remove the 3 latest changesets
45 @repository.changesets.find(:all, :order => 'id DESC', :limit => 3).each(&:destroy)
45 @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy)
46 46 @repository.reload
47 47 assert_equal 3, @repository.changesets.count
48 48
General Comments 0
You need to be logged in to leave comments. Login now