##// END OF EJS Templates
Merged r10862 from trunk to 1.4-stable (#12409)...
Toshi MARUYAMA -
r10637:68c2588f853c
parent child
Show More
@@ -1,596 +1,596
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class RepositoryGitTest < ActiveSupport::TestCase
20 class RepositoryGitTest < ActiveSupport::TestCase
21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
22
22
23 include Redmine::I18n
23 include Redmine::I18n
24
24
25 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
25 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
26 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
26 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
27
27
28 NUM_REV = 28
28 NUM_REV = 28
29 NUM_HEAD = 6
29 NUM_HEAD = 6
30
30
31 FELIX_HEX = "Felix Sch\xC3\xA4fer"
31 FELIX_HEX = "Felix Sch\xC3\xA4fer"
32 CHAR_1_HEX = "\xc3\x9c"
32 CHAR_1_HEX = "\xc3\x9c"
33
33
34 ## Git, Mercurial and CVS path encodings are binary.
34 ## Git, Mercurial and CVS path encodings are binary.
35 ## Subversion supports URL encoding for path.
35 ## Subversion supports URL encoding for path.
36 ## Redmine Mercurial adapter and extension use URL encoding.
36 ## Redmine Mercurial adapter and extension use URL encoding.
37 ## Git accepts only binary path in command line parameter.
37 ## Git accepts only binary path in command line parameter.
38 ## So, there is no way to use binary command line parameter in JRuby.
38 ## So, there is no way to use binary command line parameter in JRuby.
39 JRUBY_SKIP = (RUBY_PLATFORM == 'java')
39 JRUBY_SKIP = (RUBY_PLATFORM == 'java')
40 JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
40 JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
41
41
42 def setup
42 def setup
43 @project = Project.find(3)
43 @project = Project.find(3)
44 @repository = Repository::Git.create(
44 @repository = Repository::Git.create(
45 :project => @project,
45 :project => @project,
46 :url => REPOSITORY_PATH,
46 :url => REPOSITORY_PATH,
47 :path_encoding => 'ISO-8859-1'
47 :path_encoding => 'ISO-8859-1'
48 )
48 )
49 assert @repository
49 assert @repository
50 @char_1 = CHAR_1_HEX.dup
50 @char_1 = CHAR_1_HEX.dup
51 if @char_1.respond_to?(:force_encoding)
51 if @char_1.respond_to?(:force_encoding)
52 @char_1.force_encoding('UTF-8')
52 @char_1.force_encoding('UTF-8')
53 end
53 end
54 end
54 end
55
55
56 def test_blank_path_to_repository_error_message
56 def test_blank_path_to_repository_error_message
57 set_language_if_valid 'en'
57 set_language_if_valid 'en'
58 repo = Repository::Git.new(
58 repo = Repository::Git.new(
59 :project => @project,
59 :project => @project,
60 :identifier => 'test'
60 :identifier => 'test'
61 )
61 )
62 assert !repo.save
62 assert !repo.save
63 assert_include "Path to repository can't be blank",
63 assert_include "Path to repository can't be blank",
64 repo.errors.full_messages
64 repo.errors.full_messages
65 end
65 end
66
66
67 def test_blank_path_to_repository_error_message_fr
67 def test_blank_path_to_repository_error_message_fr
68 set_language_if_valid 'fr'
68 set_language_if_valid 'fr'
69 str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)"
69 str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)"
70 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
70 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
71 repo = Repository::Git.new(
71 repo = Repository::Git.new(
72 :project => @project,
72 :project => @project,
73 :url => "",
73 :url => "",
74 :identifier => 'test',
74 :identifier => 'test',
75 :path_encoding => ''
75 :path_encoding => ''
76 )
76 )
77 assert !repo.save
77 assert !repo.save
78 assert_include str, repo.errors.full_messages
78 assert_include str, repo.errors.full_messages
79 end
79 end
80
80
81 if File.directory?(REPOSITORY_PATH)
81 if File.directory?(REPOSITORY_PATH)
82 ## Ruby uses ANSI api to fork a process on Windows.
82 ## Ruby uses ANSI api to fork a process on Windows.
83 ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem
83 ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem
84 ## and these are incompatible with ASCII.
84 ## and these are incompatible with ASCII.
85 ## Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10
85 ## Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10
86 ## http://code.google.com/p/msysgit/issues/detail?id=80
86 ## http://code.google.com/p/msysgit/issues/detail?id=80
87 ## So, Latin-1 path tests fail on Japanese Windows
87 ## So, Latin-1 path tests fail on Japanese Windows
88 WINDOWS_PASS = (Redmine::Platform.mswin? &&
88 WINDOWS_PASS = (Redmine::Platform.mswin? &&
89 Redmine::Scm::Adapters::GitAdapter.client_version_above?([1, 7, 10]))
89 Redmine::Scm::Adapters::GitAdapter.client_version_above?([1, 7, 10]))
90 WINDOWS_SKIP_STR = "TODO: This test fails in Git for Windows above 1.7.10"
90 WINDOWS_SKIP_STR = "TODO: This test fails in Git for Windows above 1.7.10"
91
91
92 def test_scm_available
92 def test_scm_available
93 klass = Repository::Git
93 klass = Repository::Git
94 assert_equal "Git", klass.scm_name
94 assert_equal "Git", klass.scm_name
95 assert klass.scm_adapter_class
95 assert klass.scm_adapter_class
96 assert_not_equal "", klass.scm_command
96 assert_not_equal "", klass.scm_command
97 assert_equal true, klass.scm_available
97 assert_equal true, klass.scm_available
98 end
98 end
99
99
100 def test_fetch_changesets_from_scratch
100 def test_fetch_changesets_from_scratch
101 assert_nil @repository.extra_info
101 assert_nil @repository.extra_info
102
102
103 assert_equal 0, @repository.changesets.count
103 assert_equal 0, @repository.changesets.count
104 @repository.fetch_changesets
104 @repository.fetch_changesets
105 @project.reload
105 @project.reload
106
106
107 assert_equal NUM_REV, @repository.changesets.count
107 assert_equal NUM_REV, @repository.changesets.count
108 assert_equal 39, @repository.changes.count
108 assert_equal 39, @repository.changes.count
109
109
110 commit = @repository.changesets.find_by_revision("7234cb2750b63f47bff735edc50a1c0a433c2518")
110 commit = @repository.changesets.find_by_revision("7234cb2750b63f47bff735edc50a1c0a433c2518")
111 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid
111 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid
112 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
112 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
113 assert_equal "jsmith <jsmith@foo.bar>", commit.committer
113 assert_equal "jsmith <jsmith@foo.bar>", commit.committer
114 assert_equal User.find_by_login('jsmith'), commit.user
114 assert_equal User.find_by_login('jsmith'), commit.user
115 # TODO: add a commit with commit time <> author time to the test repository
115 # TODO: add a commit with commit time <> author time to the test repository
116 assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
116 assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
117 assert_equal "2007-12-14".to_date, commit.commit_date
117 assert_equal "2007-12-14".to_date, commit.commit_date
118 assert_equal 3, commit.changes.count
118 assert_equal 3, commit.changes.count
119 change = commit.changes.sort_by(&:path).first
119 change = commit.changes.sort_by(&:path).first
120 assert_equal "README", change.path
120 assert_equal "README", change.path
121 assert_equal nil, change.from_path
121 assert_equal nil, change.from_path
122 assert_equal "A", change.action
122 assert_equal "A", change.action
123
123
124 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
124 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
125 end
125 end
126
126
127 def test_fetch_changesets_incremental
127 def test_fetch_changesets_incremental
128 assert_equal 0, @repository.changesets.count
128 assert_equal 0, @repository.changesets.count
129 @repository.fetch_changesets
129 @repository.fetch_changesets
130 @project.reload
130 @project.reload
131 assert_equal NUM_REV, @repository.changesets.count
131 assert_equal NUM_REV, @repository.changesets.count
132 extra_info_heads = @repository.extra_info["heads"].dup
132 extra_info_heads = @repository.extra_info["heads"].dup
133 assert_equal NUM_HEAD, extra_info_heads.size
133 assert_equal NUM_HEAD, extra_info_heads.size
134 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
134 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
135 assert_equal 4, extra_info_heads.size
135 assert_equal 4, extra_info_heads.size
136
136
137 del_revs = [
137 del_revs = [
138 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
138 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
139 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
139 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
140 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
140 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
141 "deff712f05a90d96edbd70facc47d944be5897e3",
141 "deff712f05a90d96edbd70facc47d944be5897e3",
142 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
142 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
143 "7e61ac704deecde634b51e59daa8110435dcb3da",
143 "7e61ac704deecde634b51e59daa8110435dcb3da",
144 ]
144 ]
145 @repository.changesets.each do |rev|
145 @repository.changesets.each do |rev|
146 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
146 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
147 end
147 end
148 @project.reload
148 @project.reload
149 cs1 = @repository.changesets
149 cs1 = @repository.changesets
150 assert_equal NUM_REV - 6, cs1.count
150 assert_equal NUM_REV - 6, cs1.count
151 extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
151 extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
152 h = {}
152 h = {}
153 h["heads"] = extra_info_heads
153 h["heads"] = extra_info_heads
154 @repository.merge_extra_info(h)
154 @repository.merge_extra_info(h)
155 @repository.save
155 @repository.save
156 @project.reload
156 @project.reload
157 assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8")
157 assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8")
158 @repository.fetch_changesets
158 @repository.fetch_changesets
159 @project.reload
159 @project.reload
160 assert_equal NUM_REV, @repository.changesets.count
160 assert_equal NUM_REV, @repository.changesets.count
161 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
161 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
162 assert @repository.extra_info["heads"].index("83ca5fd546063a3c7dc2e568ba3355661a9e2b2c")
162 assert @repository.extra_info["heads"].index("83ca5fd546063a3c7dc2e568ba3355661a9e2b2c")
163 end
163 end
164
164
165 def test_fetch_changesets_history_editing
165 def test_fetch_changesets_history_editing
166 assert_equal 0, @repository.changesets.count
166 assert_equal 0, @repository.changesets.count
167 @repository.fetch_changesets
167 @repository.fetch_changesets
168 @project.reload
168 @project.reload
169 assert_equal NUM_REV, @repository.changesets.count
169 assert_equal NUM_REV, @repository.changesets.count
170 extra_info_heads = @repository.extra_info["heads"].dup
170 extra_info_heads = @repository.extra_info["heads"].dup
171 assert_equal NUM_HEAD, extra_info_heads.size
171 assert_equal NUM_HEAD, extra_info_heads.size
172 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
172 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
173 assert_equal 4, extra_info_heads.size
173 assert_equal 4, extra_info_heads.size
174
174
175 del_revs = [
175 del_revs = [
176 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
176 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
177 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
177 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
178 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
178 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
179 "deff712f05a90d96edbd70facc47d944be5897e3",
179 "deff712f05a90d96edbd70facc47d944be5897e3",
180 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
180 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
181 "7e61ac704deecde634b51e59daa8110435dcb3da",
181 "7e61ac704deecde634b51e59daa8110435dcb3da",
182 ]
182 ]
183 @repository.changesets.each do |rev|
183 @repository.changesets.each do |rev|
184 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
184 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
185 end
185 end
186 @project.reload
186 @project.reload
187 assert_equal NUM_REV - 6, @repository.changesets.count
187 assert_equal NUM_REV - 6, @repository.changesets.count
188
188
189 c = Changeset.new(:repository => @repository,
189 c = Changeset.new(:repository => @repository,
190 :committed_on => Time.now,
190 :committed_on => Time.now,
191 :revision => "abcd1234efgh",
191 :revision => "abcd1234efgh",
192 :scmid => "abcd1234efgh",
192 :scmid => "abcd1234efgh",
193 :comments => 'test')
193 :comments => 'test')
194 assert c.save
194 assert c.save
195 @project.reload
195 @project.reload
196 assert_equal NUM_REV - 5, @repository.changesets.count
196 assert_equal NUM_REV - 5, @repository.changesets.count
197
197
198 extra_info_heads << "1234abcd5678"
198 extra_info_heads << "1234abcd5678"
199 h = {}
199 h = {}
200 h["heads"] = extra_info_heads
200 h["heads"] = extra_info_heads
201 @repository.merge_extra_info(h)
201 @repository.merge_extra_info(h)
202 @repository.save
202 @repository.save
203 @project.reload
203 @project.reload
204 h1 = @repository.extra_info["heads"].dup
204 h1 = @repository.extra_info["heads"].dup
205 assert h1.index("1234abcd5678")
205 assert h1.index("1234abcd5678")
206 assert_equal 5, h1.size
206 assert_equal 5, h1.size
207
207
208 @repository.fetch_changesets
208 @repository.fetch_changesets
209 @project.reload
209 @project.reload
210 assert_equal NUM_REV - 5, @repository.changesets.count
210 assert_equal NUM_REV - 5, @repository.changesets.count
211 h2 = @repository.extra_info["heads"].dup
211 h2 = @repository.extra_info["heads"].dup
212 assert_equal h1, h2
212 assert_equal h1, h2
213 end
213 end
214
214
215 def test_keep_extra_report_last_commit_in_clear_changesets
215 def test_keep_extra_report_last_commit_in_clear_changesets
216 assert_nil @repository.extra_info
216 assert_nil @repository.extra_info
217 h = {}
217 h = {}
218 h["extra_report_last_commit"] = 1
218 h["extra_report_last_commit"] = "1"
219 @repository.merge_extra_info(h)
219 @repository.merge_extra_info(h)
220 @repository.save
220 @repository.save
221 @project.reload
221 @project.reload
222
222
223 assert_equal 0, @repository.changesets.count
223 assert_equal 0, @repository.changesets.count
224 @repository.fetch_changesets
224 @repository.fetch_changesets
225 @project.reload
225 @project.reload
226
226
227 assert_equal NUM_REV, @repository.changesets.count
227 assert_equal NUM_REV, @repository.changesets.count
228 @repository.send(:clear_changesets)
228 @repository.send(:clear_changesets)
229 assert_equal 1, @repository.extra_info.size
229 assert_equal 1, @repository.extra_info.size
230 assert_equal 1, @repository.extra_info["extra_report_last_commit"]
230 assert_equal "1", @repository.extra_info["extra_report_last_commit"]
231 end
231 end
232
232
233 def test_refetch_after_clear_changesets
233 def test_refetch_after_clear_changesets
234 assert_nil @repository.extra_info
234 assert_nil @repository.extra_info
235 assert_equal 0, @repository.changesets.count
235 assert_equal 0, @repository.changesets.count
236 @repository.fetch_changesets
236 @repository.fetch_changesets
237 @project.reload
237 @project.reload
238 assert_equal NUM_REV, @repository.changesets.count
238 assert_equal NUM_REV, @repository.changesets.count
239
239
240 @repository.send(:clear_changesets)
240 @repository.send(:clear_changesets)
241 @project.reload
241 @project.reload
242 assert_equal 0, @repository.changesets.count
242 assert_equal 0, @repository.changesets.count
243
243
244 @repository.fetch_changesets
244 @repository.fetch_changesets
245 @project.reload
245 @project.reload
246 assert_equal NUM_REV, @repository.changesets.count
246 assert_equal NUM_REV, @repository.changesets.count
247 end
247 end
248
248
249 def test_parents
249 def test_parents
250 assert_equal 0, @repository.changesets.count
250 assert_equal 0, @repository.changesets.count
251 @repository.fetch_changesets
251 @repository.fetch_changesets
252 @project.reload
252 @project.reload
253 assert_equal NUM_REV, @repository.changesets.count
253 assert_equal NUM_REV, @repository.changesets.count
254 r1 = @repository.find_changeset_by_name("7234cb2750b63")
254 r1 = @repository.find_changeset_by_name("7234cb2750b63")
255 assert_equal [], r1.parents
255 assert_equal [], r1.parents
256 r2 = @repository.find_changeset_by_name("899a15dba03a3")
256 r2 = @repository.find_changeset_by_name("899a15dba03a3")
257 assert_equal 1, r2.parents.length
257 assert_equal 1, r2.parents.length
258 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518",
258 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518",
259 r2.parents[0].identifier
259 r2.parents[0].identifier
260 r3 = @repository.find_changeset_by_name("32ae898b720c2")
260 r3 = @repository.find_changeset_by_name("32ae898b720c2")
261 assert_equal 2, r3.parents.length
261 assert_equal 2, r3.parents.length
262 r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort
262 r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort
263 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", r4[0]
263 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", r4[0]
264 assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", r4[1]
264 assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", r4[1]
265 end
265 end
266
266
267 def test_db_consistent_ordering_init
267 def test_db_consistent_ordering_init
268 assert_nil @repository.extra_info
268 assert_nil @repository.extra_info
269 assert_equal 0, @repository.changesets.count
269 assert_equal 0, @repository.changesets.count
270 @repository.fetch_changesets
270 @repository.fetch_changesets
271 @project.reload
271 @project.reload
272 assert_equal 1, @repository.extra_info["db_consistent"]["ordering"]
272 assert_equal 1, @repository.extra_info["db_consistent"]["ordering"]
273 end
273 end
274
274
275 def test_db_consistent_ordering_before_1_2
275 def test_db_consistent_ordering_before_1_2
276 assert_nil @repository.extra_info
276 assert_nil @repository.extra_info
277 assert_equal 0, @repository.changesets.count
277 assert_equal 0, @repository.changesets.count
278 @repository.fetch_changesets
278 @repository.fetch_changesets
279 @project.reload
279 @project.reload
280 assert_equal NUM_REV, @repository.changesets.count
280 assert_equal NUM_REV, @repository.changesets.count
281 assert_not_nil @repository.extra_info
281 assert_not_nil @repository.extra_info
282 h = {}
282 h = {}
283 h["heads"] = []
283 h["heads"] = []
284 h["branches"] = {}
284 h["branches"] = {}
285 h["db_consistent"] = {}
285 h["db_consistent"] = {}
286 @repository.merge_extra_info(h)
286 @repository.merge_extra_info(h)
287 @repository.save
287 @repository.save
288 assert_equal NUM_REV, @repository.changesets.count
288 assert_equal NUM_REV, @repository.changesets.count
289 @repository.fetch_changesets
289 @repository.fetch_changesets
290 @project.reload
290 @project.reload
291 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
291 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
292
292
293 extra_info_heads = @repository.extra_info["heads"].dup
293 extra_info_heads = @repository.extra_info["heads"].dup
294 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
294 extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" }
295 del_revs = [
295 del_revs = [
296 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
296 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
297 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
297 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
298 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
298 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
299 "deff712f05a90d96edbd70facc47d944be5897e3",
299 "deff712f05a90d96edbd70facc47d944be5897e3",
300 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
300 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
301 "7e61ac704deecde634b51e59daa8110435dcb3da",
301 "7e61ac704deecde634b51e59daa8110435dcb3da",
302 ]
302 ]
303 @repository.changesets.each do |rev|
303 @repository.changesets.each do |rev|
304 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
304 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
305 end
305 end
306 @project.reload
306 @project.reload
307 cs1 = @repository.changesets
307 cs1 = @repository.changesets
308 assert_equal NUM_REV - 6, cs1.count
308 assert_equal NUM_REV - 6, cs1.count
309 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
309 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
310
310
311 extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
311 extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
312 h = {}
312 h = {}
313 h["heads"] = extra_info_heads
313 h["heads"] = extra_info_heads
314 @repository.merge_extra_info(h)
314 @repository.merge_extra_info(h)
315 @repository.save
315 @repository.save
316 @project.reload
316 @project.reload
317 assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8")
317 assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8")
318 @repository.fetch_changesets
318 @repository.fetch_changesets
319 @project.reload
319 @project.reload
320 assert_equal NUM_REV, @repository.changesets.count
320 assert_equal NUM_REV, @repository.changesets.count
321 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
321 assert_equal NUM_HEAD, @repository.extra_info["heads"].size
322
322
323 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
323 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
324 end
324 end
325
325
326 def test_heads_from_branches_hash
326 def test_heads_from_branches_hash
327 assert_nil @repository.extra_info
327 assert_nil @repository.extra_info
328 assert_equal 0, @repository.changesets.count
328 assert_equal 0, @repository.changesets.count
329 assert_equal [], @repository.heads_from_branches_hash
329 assert_equal [], @repository.heads_from_branches_hash
330 h = {}
330 h = {}
331 h["branches"] = {}
331 h["branches"] = {}
332 h["branches"]["test1"] = {}
332 h["branches"]["test1"] = {}
333 h["branches"]["test1"]["last_scmid"] = "1234abcd"
333 h["branches"]["test1"]["last_scmid"] = "1234abcd"
334 h["branches"]["test2"] = {}
334 h["branches"]["test2"] = {}
335 h["branches"]["test2"]["last_scmid"] = "abcd1234"
335 h["branches"]["test2"]["last_scmid"] = "abcd1234"
336 @repository.merge_extra_info(h)
336 @repository.merge_extra_info(h)
337 @repository.save
337 @repository.save
338 @project.reload
338 @project.reload
339 assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort
339 assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort
340 end
340 end
341
341
342 def test_latest_changesets
342 def test_latest_changesets
343 assert_equal 0, @repository.changesets.count
343 assert_equal 0, @repository.changesets.count
344 @repository.fetch_changesets
344 @repository.fetch_changesets
345 @project.reload
345 @project.reload
346 assert_equal NUM_REV, @repository.changesets.count
346 assert_equal NUM_REV, @repository.changesets.count
347 # with limit
347 # with limit
348 changesets = @repository.latest_changesets('', 'master', 2)
348 changesets = @repository.latest_changesets('', 'master', 2)
349 assert_equal 2, changesets.size
349 assert_equal 2, changesets.size
350
350
351 # with path
351 # with path
352 changesets = @repository.latest_changesets('images', 'master')
352 changesets = @repository.latest_changesets('images', 'master')
353 assert_equal [
353 assert_equal [
354 'deff712f05a90d96edbd70facc47d944be5897e3',
354 'deff712f05a90d96edbd70facc47d944be5897e3',
355 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
355 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
356 '7234cb2750b63f47bff735edc50a1c0a433c2518',
356 '7234cb2750b63f47bff735edc50a1c0a433c2518',
357 ], changesets.collect(&:revision)
357 ], changesets.collect(&:revision)
358
358
359 changesets = @repository.latest_changesets('README', nil)
359 changesets = @repository.latest_changesets('README', nil)
360 assert_equal [
360 assert_equal [
361 '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf',
361 '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf',
362 '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8',
362 '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8',
363 '713f4944648826f558cf548222f813dabe7cbb04',
363 '713f4944648826f558cf548222f813dabe7cbb04',
364 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
364 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
365 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
365 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
366 '7234cb2750b63f47bff735edc50a1c0a433c2518',
366 '7234cb2750b63f47bff735edc50a1c0a433c2518',
367 ], changesets.collect(&:revision)
367 ], changesets.collect(&:revision)
368
368
369 # with path, revision and limit
369 # with path, revision and limit
370 changesets = @repository.latest_changesets('images', '899a15dba')
370 changesets = @repository.latest_changesets('images', '899a15dba')
371 assert_equal [
371 assert_equal [
372 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
372 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
373 '7234cb2750b63f47bff735edc50a1c0a433c2518',
373 '7234cb2750b63f47bff735edc50a1c0a433c2518',
374 ], changesets.collect(&:revision)
374 ], changesets.collect(&:revision)
375
375
376 changesets = @repository.latest_changesets('images', '899a15dba', 1)
376 changesets = @repository.latest_changesets('images', '899a15dba', 1)
377 assert_equal [
377 assert_equal [
378 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
378 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
379 ], changesets.collect(&:revision)
379 ], changesets.collect(&:revision)
380
380
381 changesets = @repository.latest_changesets('README', '899a15dba')
381 changesets = @repository.latest_changesets('README', '899a15dba')
382 assert_equal [
382 assert_equal [
383 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
383 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
384 '7234cb2750b63f47bff735edc50a1c0a433c2518',
384 '7234cb2750b63f47bff735edc50a1c0a433c2518',
385 ], changesets.collect(&:revision)
385 ], changesets.collect(&:revision)
386
386
387 changesets = @repository.latest_changesets('README', '899a15dba', 1)
387 changesets = @repository.latest_changesets('README', '899a15dba', 1)
388 assert_equal [
388 assert_equal [
389 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
389 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
390 ], changesets.collect(&:revision)
390 ], changesets.collect(&:revision)
391
391
392 # with path, tag and limit
392 # with path, tag and limit
393 changesets = @repository.latest_changesets('images', 'tag01.annotated')
393 changesets = @repository.latest_changesets('images', 'tag01.annotated')
394 assert_equal [
394 assert_equal [
395 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
395 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
396 '7234cb2750b63f47bff735edc50a1c0a433c2518',
396 '7234cb2750b63f47bff735edc50a1c0a433c2518',
397 ], changesets.collect(&:revision)
397 ], changesets.collect(&:revision)
398
398
399 changesets = @repository.latest_changesets('images', 'tag01.annotated', 1)
399 changesets = @repository.latest_changesets('images', 'tag01.annotated', 1)
400 assert_equal [
400 assert_equal [
401 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
401 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
402 ], changesets.collect(&:revision)
402 ], changesets.collect(&:revision)
403
403
404 changesets = @repository.latest_changesets('README', 'tag01.annotated')
404 changesets = @repository.latest_changesets('README', 'tag01.annotated')
405 assert_equal [
405 assert_equal [
406 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
406 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
407 '7234cb2750b63f47bff735edc50a1c0a433c2518',
407 '7234cb2750b63f47bff735edc50a1c0a433c2518',
408 ], changesets.collect(&:revision)
408 ], changesets.collect(&:revision)
409
409
410 changesets = @repository.latest_changesets('README', 'tag01.annotated', 1)
410 changesets = @repository.latest_changesets('README', 'tag01.annotated', 1)
411 assert_equal [
411 assert_equal [
412 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
412 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
413 ], changesets.collect(&:revision)
413 ], changesets.collect(&:revision)
414
414
415 # with path, branch and limit
415 # with path, branch and limit
416 changesets = @repository.latest_changesets('images', 'test_branch')
416 changesets = @repository.latest_changesets('images', 'test_branch')
417 assert_equal [
417 assert_equal [
418 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
418 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
419 '7234cb2750b63f47bff735edc50a1c0a433c2518',
419 '7234cb2750b63f47bff735edc50a1c0a433c2518',
420 ], changesets.collect(&:revision)
420 ], changesets.collect(&:revision)
421
421
422 changesets = @repository.latest_changesets('images', 'test_branch', 1)
422 changesets = @repository.latest_changesets('images', 'test_branch', 1)
423 assert_equal [
423 assert_equal [
424 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
424 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
425 ], changesets.collect(&:revision)
425 ], changesets.collect(&:revision)
426
426
427 changesets = @repository.latest_changesets('README', 'test_branch')
427 changesets = @repository.latest_changesets('README', 'test_branch')
428 assert_equal [
428 assert_equal [
429 '713f4944648826f558cf548222f813dabe7cbb04',
429 '713f4944648826f558cf548222f813dabe7cbb04',
430 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
430 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
431 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
431 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
432 '7234cb2750b63f47bff735edc50a1c0a433c2518',
432 '7234cb2750b63f47bff735edc50a1c0a433c2518',
433 ], changesets.collect(&:revision)
433 ], changesets.collect(&:revision)
434
434
435 changesets = @repository.latest_changesets('README', 'test_branch', 2)
435 changesets = @repository.latest_changesets('README', 'test_branch', 2)
436 assert_equal [
436 assert_equal [
437 '713f4944648826f558cf548222f813dabe7cbb04',
437 '713f4944648826f558cf548222f813dabe7cbb04',
438 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
438 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
439 ], changesets.collect(&:revision)
439 ], changesets.collect(&:revision)
440
440
441 if WINDOWS_PASS
441 if WINDOWS_PASS
442 puts WINDOWS_SKIP_STR
442 puts WINDOWS_SKIP_STR
443 elsif JRUBY_SKIP
443 elsif JRUBY_SKIP
444 puts JRUBY_SKIP_STR
444 puts JRUBY_SKIP_STR
445 else
445 else
446 # latin-1 encoding path
446 # latin-1 encoding path
447 changesets = @repository.latest_changesets(
447 changesets = @repository.latest_changesets(
448 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89')
448 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89')
449 assert_equal [
449 assert_equal [
450 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
450 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
451 '4fc55c43bf3d3dc2efb66145365ddc17639ce81e',
451 '4fc55c43bf3d3dc2efb66145365ddc17639ce81e',
452 ], changesets.collect(&:revision)
452 ], changesets.collect(&:revision)
453
453
454 changesets = @repository.latest_changesets(
454 changesets = @repository.latest_changesets(
455 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1)
455 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1)
456 assert_equal [
456 assert_equal [
457 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
457 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
458 ], changesets.collect(&:revision)
458 ], changesets.collect(&:revision)
459 end
459 end
460 end
460 end
461
461
462 def test_latest_changesets_latin_1_dir
462 def test_latest_changesets_latin_1_dir
463 if WINDOWS_PASS
463 if WINDOWS_PASS
464 puts WINDOWS_SKIP_STR
464 puts WINDOWS_SKIP_STR
465 elsif JRUBY_SKIP
465 elsif JRUBY_SKIP
466 puts JRUBY_SKIP_STR
466 puts JRUBY_SKIP_STR
467 else
467 else
468 assert_equal 0, @repository.changesets.count
468 assert_equal 0, @repository.changesets.count
469 @repository.fetch_changesets
469 @repository.fetch_changesets
470 @project.reload
470 @project.reload
471 assert_equal NUM_REV, @repository.changesets.count
471 assert_equal NUM_REV, @repository.changesets.count
472 changesets = @repository.latest_changesets(
472 changesets = @repository.latest_changesets(
473 "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed')
473 "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed')
474 assert_equal [
474 assert_equal [
475 '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127',
475 '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127',
476 ], changesets.collect(&:revision)
476 ], changesets.collect(&:revision)
477 end
477 end
478 end
478 end
479
479
480 def test_find_changeset_by_name
480 def test_find_changeset_by_name
481 assert_equal 0, @repository.changesets.count
481 assert_equal 0, @repository.changesets.count
482 @repository.fetch_changesets
482 @repository.fetch_changesets
483 @project.reload
483 @project.reload
484 assert_equal NUM_REV, @repository.changesets.count
484 assert_equal NUM_REV, @repository.changesets.count
485 ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r|
485 ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r|
486 assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518',
486 assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518',
487 @repository.find_changeset_by_name(r).revision
487 @repository.find_changeset_by_name(r).revision
488 end
488 end
489 end
489 end
490
490
491 def test_find_changeset_by_empty_name
491 def test_find_changeset_by_empty_name
492 assert_equal 0, @repository.changesets.count
492 assert_equal 0, @repository.changesets.count
493 @repository.fetch_changesets
493 @repository.fetch_changesets
494 @project.reload
494 @project.reload
495 assert_equal NUM_REV, @repository.changesets.count
495 assert_equal NUM_REV, @repository.changesets.count
496 ['', ' ', nil].each do |r|
496 ['', ' ', nil].each do |r|
497 assert_nil @repository.find_changeset_by_name(r)
497 assert_nil @repository.find_changeset_by_name(r)
498 end
498 end
499 end
499 end
500
500
501 def test_identifier
501 def test_identifier
502 assert_equal 0, @repository.changesets.count
502 assert_equal 0, @repository.changesets.count
503 @repository.fetch_changesets
503 @repository.fetch_changesets
504 @project.reload
504 @project.reload
505 assert_equal NUM_REV, @repository.changesets.count
505 assert_equal NUM_REV, @repository.changesets.count
506 c = @repository.changesets.find_by_revision(
506 c = @repository.changesets.find_by_revision(
507 '7234cb2750b63f47bff735edc50a1c0a433c2518')
507 '7234cb2750b63f47bff735edc50a1c0a433c2518')
508 assert_equal c.scmid, c.identifier
508 assert_equal c.scmid, c.identifier
509 end
509 end
510
510
511 def test_format_identifier
511 def test_format_identifier
512 assert_equal 0, @repository.changesets.count
512 assert_equal 0, @repository.changesets.count
513 @repository.fetch_changesets
513 @repository.fetch_changesets
514 @project.reload
514 @project.reload
515 assert_equal NUM_REV, @repository.changesets.count
515 assert_equal NUM_REV, @repository.changesets.count
516 c = @repository.changesets.find_by_revision(
516 c = @repository.changesets.find_by_revision(
517 '7234cb2750b63f47bff735edc50a1c0a433c2518')
517 '7234cb2750b63f47bff735edc50a1c0a433c2518')
518 assert_equal '7234cb27', c.format_identifier
518 assert_equal '7234cb27', c.format_identifier
519 end
519 end
520
520
521 def test_activities
521 def test_activities
522 c = Changeset.new(:repository => @repository,
522 c = Changeset.new(:repository => @repository,
523 :committed_on => Time.now,
523 :committed_on => Time.now,
524 :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
524 :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
525 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
525 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
526 :comments => 'test')
526 :comments => 'test')
527 assert c.event_title.include?('abc7234c:')
527 assert c.event_title.include?('abc7234c:')
528 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev]
528 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev]
529 end
529 end
530
530
531 def test_log_utf8
531 def test_log_utf8
532 assert_equal 0, @repository.changesets.count
532 assert_equal 0, @repository.changesets.count
533 @repository.fetch_changesets
533 @repository.fetch_changesets
534 @project.reload
534 @project.reload
535 assert_equal NUM_REV, @repository.changesets.count
535 assert_equal NUM_REV, @repository.changesets.count
536 str_felix_hex = FELIX_HEX.dup
536 str_felix_hex = FELIX_HEX.dup
537 if str_felix_hex.respond_to?(:force_encoding)
537 if str_felix_hex.respond_to?(:force_encoding)
538 str_felix_hex.force_encoding('UTF-8')
538 str_felix_hex.force_encoding('UTF-8')
539 end
539 end
540 c = @repository.changesets.find_by_revision(
540 c = @repository.changesets.find_by_revision(
541 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b')
541 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b')
542 assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer
542 assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer
543 end
543 end
544
544
545 def test_previous
545 def test_previous
546 assert_equal 0, @repository.changesets.count
546 assert_equal 0, @repository.changesets.count
547 @repository.fetch_changesets
547 @repository.fetch_changesets
548 @project.reload
548 @project.reload
549 assert_equal NUM_REV, @repository.changesets.count
549 assert_equal NUM_REV, @repository.changesets.count
550 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
550 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
551 changeset = @repository.find_changeset_by_name(r1)
551 changeset = @repository.find_changeset_by_name(r1)
552 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
552 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
553 assert_equal @repository.find_changeset_by_name(r2), changeset.previous
553 assert_equal @repository.find_changeset_by_name(r2), changeset.previous
554 end
554 end
555 end
555 end
556 end
556 end
557
557
558 def test_previous_nil
558 def test_previous_nil
559 assert_equal 0, @repository.changesets.count
559 assert_equal 0, @repository.changesets.count
560 @repository.fetch_changesets
560 @repository.fetch_changesets
561 @project.reload
561 @project.reload
562 assert_equal NUM_REV, @repository.changesets.count
562 assert_equal NUM_REV, @repository.changesets.count
563 %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb275|.each do |r1|
563 %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb275|.each do |r1|
564 changeset = @repository.find_changeset_by_name(r1)
564 changeset = @repository.find_changeset_by_name(r1)
565 assert_nil changeset.previous
565 assert_nil changeset.previous
566 end
566 end
567 end
567 end
568
568
569 def test_next
569 def test_next
570 assert_equal 0, @repository.changesets.count
570 assert_equal 0, @repository.changesets.count
571 @repository.fetch_changesets
571 @repository.fetch_changesets
572 @project.reload
572 @project.reload
573 assert_equal NUM_REV, @repository.changesets.count
573 assert_equal NUM_REV, @repository.changesets.count
574 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
574 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
575 changeset = @repository.find_changeset_by_name(r2)
575 changeset = @repository.find_changeset_by_name(r2)
576 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
576 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
577 assert_equal @repository.find_changeset_by_name(r1), changeset.next
577 assert_equal @repository.find_changeset_by_name(r1), changeset.next
578 end
578 end
579 end
579 end
580 end
580 end
581
581
582 def test_next_nil
582 def test_next_nil
583 assert_equal 0, @repository.changesets.count
583 assert_equal 0, @repository.changesets.count
584 @repository.fetch_changesets
584 @repository.fetch_changesets
585 @project.reload
585 @project.reload
586 assert_equal NUM_REV, @repository.changesets.count
586 assert_equal NUM_REV, @repository.changesets.count
587 %w|2a682156a3b6e77a8bf9cd4590e8db757f3c6c78 2a682156a3b6e77a|.each do |r1|
587 %w|2a682156a3b6e77a8bf9cd4590e8db757f3c6c78 2a682156a3b6e77a|.each do |r1|
588 changeset = @repository.find_changeset_by_name(r1)
588 changeset = @repository.find_changeset_by_name(r1)
589 assert_nil changeset.next
589 assert_nil changeset.next
590 end
590 end
591 end
591 end
592 else
592 else
593 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
593 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
594 def test_fake; assert true end
594 def test_fake; assert true end
595 end
595 end
596 end
596 end
General Comments 0
You need to be logged in to leave comments. Login now