scm: git: fix changesets aren't read after clear_changesets call (#12409)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10856 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2012-11-21 07:44:29 +00:00
parent 7048f66619
commit 5d8d38aa60
3 changed files with 48 additions and 0 deletions

View File

@ -427,5 +427,9 @@ class Repository < ActiveRecord::Base
connection.delete("DELETE FROM #{ci} WHERE #{ci}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})") connection.delete("DELETE FROM #{ci} WHERE #{ci}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
connection.delete("DELETE FROM #{cp} WHERE #{cp}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})") connection.delete("DELETE FROM #{cp} WHERE #{cp}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}") connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}")
clear_extra_info_of_changesets
end
def clear_extra_info_of_changesets
end end
end end

View File

@ -255,4 +255,14 @@ class Repository::Git < Repository
:order => 'committed_on DESC' :order => 'committed_on DESC'
) )
end end
def clear_extra_info_of_changesets
v = extra_info["extra_report_last_commit"]
write_attribute(:extra_info, nil)
h = {}
h["extra_report_last_commit"] = v
merge_extra_info(h)
self.save
end
private :clear_extra_info_of_changesets
end end

View File

@ -217,6 +217,40 @@ class RepositoryGitTest < ActiveSupport::TestCase
assert_equal h1, h2 assert_equal h1, h2
end end
def test_keep_extra_report_last_commit_in_clear_changesets
assert_nil @repository.extra_info
h = {}
h["extra_report_last_commit"] = 1
@repository.merge_extra_info(h)
@repository.save
@project.reload
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
@project.reload
assert_equal NUM_REV, @repository.changesets.count
@repository.send(:clear_changesets)
assert_equal 1, @repository.extra_info.size
assert_equal 1, @repository.extra_info["extra_report_last_commit"]
end
def test_refetch_after_clear_changesets
assert_nil @repository.extra_info
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
@project.reload
assert_equal NUM_REV, @repository.changesets.count
@repository.send(:clear_changesets)
@project.reload
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
@project.reload
assert_equal NUM_REV, @repository.changesets.count
end
def test_parents def test_parents
assert_equal 0, @repository.changesets.count assert_equal 0, @repository.changesets.count
@repository.fetch_changesets @repository.fetch_changesets