summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-11-21 09:55:48 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-11-21 09:55:48 +0000
commit06b68f194811325d7d4a33fe942af478d5c3786f (patch)
tree692b1b37da82bf2b53a50ada9bc6ed51072c5a46
parentb51203bc831da877e8d53cbc6a3d6e6638b5156c (diff)
downloadredmine-06b68f194811325d7d4a33fe942af478d5c3786f.tar.gz
redmine-06b68f194811325d7d4a33fe942af478d5c3786f.zip
Merged r10856 and r10857 from trunk to 2.1-stable (#12409)
scm: git: fix changesets aren't read after clear_changesets call. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.1-stable@10858 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/repository.rb4
-rw-r--r--app/models/repository/git.rb11
-rw-r--r--test/unit/repository_git_test.rb34
3 files changed, 49 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 9a6891a90..1ef73a453 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -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 #{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}")
+ clear_extra_info_of_changesets
+ end
+
+ def clear_extra_info_of_changesets
end
end
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index 064a67494..e07e7c804 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -255,4 +255,15 @@ class Repository::Git < Repository
:order => 'committed_on DESC'
)
end
+
+ def clear_extra_info_of_changesets
+ return if extra_info.nil?
+ 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
diff --git a/test/unit/repository_git_test.rb b/test/unit/repository_git_test.rb
index cfb0f486c..fa2f8bce6 100644
--- a/test/unit/repository_git_test.rb
+++ b/test/unit/repository_git_test.rb
@@ -217,6 +217,40 @@ class RepositoryGitTest < ActiveSupport::TestCase
assert_equal h1, h2
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
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets