##// END OF EJS Templates
Rails3: scm: git: fix error of test_fetch_changesets_incremental at unit model test...
Toshi MARUYAMA -
r6945:63b9005f4541
parent child
Show More
@@ -1,454 +1,456
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 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
23 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
24 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
24 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
25
25
26 NUM_REV = 21
26 NUM_REV = 21
27
27
28 FELIX_HEX = "Felix Sch\xC3\xA4fer"
28 FELIX_HEX = "Felix Sch\xC3\xA4fer"
29 CHAR_1_HEX = "\xc3\x9c"
29 CHAR_1_HEX = "\xc3\x9c"
30
30
31 ## Ruby uses ANSI api to fork a process on Windows.
31 ## Ruby uses ANSI api to fork a process on Windows.
32 ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem
32 ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem
33 ## and these are incompatible with ASCII.
33 ## and these are incompatible with ASCII.
34 # WINDOWS_PASS = Redmine::Platform.mswin?
34 # WINDOWS_PASS = Redmine::Platform.mswin?
35 WINDOWS_PASS = false
35 WINDOWS_PASS = false
36
36
37 ## Git, Mercurial and CVS path encodings are binary.
37 ## Git, Mercurial and CVS path encodings are binary.
38 ## Subversion supports URL encoding for path.
38 ## Subversion supports URL encoding for path.
39 ## Redmine Mercurial adapter and extension use URL encoding.
39 ## Redmine Mercurial adapter and extension use URL encoding.
40 ## Git accepts only binary path in command line parameter.
40 ## Git accepts only binary path in command line parameter.
41 ## So, there is no way to use binary command line parameter in JRuby.
41 ## So, there is no way to use binary command line parameter in JRuby.
42 JRUBY_SKIP = (RUBY_PLATFORM == 'java')
42 JRUBY_SKIP = (RUBY_PLATFORM == 'java')
43 JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
43 JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
44
44
45 if File.directory?(REPOSITORY_PATH)
45 if File.directory?(REPOSITORY_PATH)
46 def setup
46 def setup
47 klass = Repository::Git
47 klass = Repository::Git
48 assert_equal "Git", klass.scm_name
48 assert_equal "Git", klass.scm_name
49 assert klass.scm_adapter_class
49 assert klass.scm_adapter_class
50 assert_not_equal "", klass.scm_command
50 assert_not_equal "", klass.scm_command
51 assert_equal true, klass.scm_available
51 assert_equal true, klass.scm_available
52
52
53 @project = Project.find(3)
53 @project = Project.find(3)
54 @repository = Repository::Git.create(
54 @repository = Repository::Git.create(
55 :project => @project,
55 :project => @project,
56 :url => REPOSITORY_PATH,
56 :url => REPOSITORY_PATH,
57 :path_encoding => 'ISO-8859-1'
57 :path_encoding => 'ISO-8859-1'
58 )
58 )
59 assert @repository
59 assert @repository
60 @char_1 = CHAR_1_HEX.dup
60 @char_1 = CHAR_1_HEX.dup
61 if @char_1.respond_to?(:force_encoding)
61 if @char_1.respond_to?(:force_encoding)
62 @char_1.force_encoding('UTF-8')
62 @char_1.force_encoding('UTF-8')
63 end
63 end
64 end
64 end
65
65
66 def test_fetch_changesets_from_scratch
66 def test_fetch_changesets_from_scratch
67 assert_nil @repository.extra_info
67 assert_nil @repository.extra_info
68
68
69 assert_equal 0, @repository.changesets.count
69 assert_equal 0, @repository.changesets.count
70 @repository.fetch_changesets
70 @repository.fetch_changesets
71 @project.reload
71 @project.reload
72
72
73 assert_equal NUM_REV, @repository.changesets.count
73 assert_equal NUM_REV, @repository.changesets.count
74 assert_equal 33, @repository.changes.count
74 assert_equal 33, @repository.changes.count
75
75
76 commit = @repository.changesets.find(:first, :order => 'committed_on ASC')
76 commit = @repository.changesets.find(:first, :order => 'committed_on ASC')
77 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
77 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
78 assert_equal "jsmith <jsmith@foo.bar>", commit.committer
78 assert_equal "jsmith <jsmith@foo.bar>", commit.committer
79 assert_equal User.find_by_login('jsmith'), commit.user
79 assert_equal User.find_by_login('jsmith'), commit.user
80 # TODO: add a commit with commit time <> author time to the test repository
80 # TODO: add a commit with commit time <> author time to the test repository
81 assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
81 assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
82 assert_equal "2007-12-14".to_date, commit.commit_date
82 assert_equal "2007-12-14".to_date, commit.commit_date
83 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision
83 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision
84 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid
84 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid
85 assert_equal 3, commit.changes.count
85 assert_equal 3, commit.changes.count
86 change = commit.changes.sort_by(&:path).first
86 change = commit.changes.sort_by(&:path).first
87 assert_equal "README", change.path
87 assert_equal "README", change.path
88 assert_equal "A", change.action
88 assert_equal "A", change.action
89
89
90 assert_equal 4, @repository.extra_info["branches"].size
90 assert_equal 4, @repository.extra_info["branches"].size
91 end
91 end
92
92
93 def test_fetch_changesets_incremental
93 def test_fetch_changesets_incremental
94 assert_equal 0, @repository.changesets.count
94 @repository.fetch_changesets
95 @repository.fetch_changesets
95 @repository.reload
96 @project.reload
96 assert_equal 21, @repository.changesets.count
97 assert_equal NUM_REV, @repository.changesets.count
97 assert_equal 33, @repository.changes.count
98 assert_equal 33, @repository.changes.count
98 extra_info_db = @repository.extra_info["branches"]
99 extra_info_db = @repository.extra_info["branches"]
99 assert_equal 4, extra_info_db.size
100 assert_equal 4, extra_info_db.size
100 assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127",
101 assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127",
101 extra_info_db["latin-1-path-encoding"]["last_scmid"]
102 extra_info_db["latin-1-path-encoding"]["last_scmid"]
102 assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
103 assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
103 extra_info_db["master"]["last_scmid"]
104 extra_info_db["master"]["last_scmid"]
104
105
105 del_revs = [
106 del_revs = [
106 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
107 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
107 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
108 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
108 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
109 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
109 "deff712f05a90d96edbd70facc47d944be5897e3",
110 "deff712f05a90d96edbd70facc47d944be5897e3",
110 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
111 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
111 "7e61ac704deecde634b51e59daa8110435dcb3da",
112 "7e61ac704deecde634b51e59daa8110435dcb3da",
112 ]
113 ]
113 @repository.changesets.each do |rev|
114 @repository.changesets.each do |rev|
114 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
115 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
115 end
116 end
116 @repository.reload
117 @project.reload
117 cs1 = @repository.changesets
118 cs1 = @repository.changesets
118 assert_equal 15, cs1.count
119 assert_equal 15, cs1.count
119 h = @repository.extra_info.dup
120 h = @repository.extra_info.dup
120 h["branches"]["master"]["last_scmid"] =
121 h["branches"]["master"]["last_scmid"] =
121 "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
122 "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
122 @repository.merge_extra_info(h)
123 @repository.merge_extra_info(h)
123 @repository.save
124 @repository.save
124 @repository.reload
125 @project.reload
125 extra_info_db_1 = @repository.extra_info["branches"]
126 extra_info_db_1 = @repository.extra_info["branches"]
126 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8",
127 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8",
127 extra_info_db_1["master"]["last_scmid"]
128 extra_info_db_1["master"]["last_scmid"]
128
129
129 @repository.fetch_changesets
130 @repository.fetch_changesets
130 assert_equal 21, @repository.changesets.count
131 @project.reload
132 assert_equal NUM_REV, @repository.changesets.count
131 end
133 end
132
134
133 def test_fetch_changesets_invalid_rev
135 def test_fetch_changesets_invalid_rev
134 @repository.fetch_changesets
136 @repository.fetch_changesets
135 @repository.reload
137 @repository.reload
136 assert_equal 21, @repository.changesets.count
138 assert_equal 21, @repository.changesets.count
137 assert_equal 33, @repository.changes.count
139 assert_equal 33, @repository.changes.count
138 extra_info_db = @repository.extra_info["branches"]
140 extra_info_db = @repository.extra_info["branches"]
139 assert_equal 4, extra_info_db.size
141 assert_equal 4, extra_info_db.size
140 assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127",
142 assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127",
141 extra_info_db["latin-1-path-encoding"]["last_scmid"]
143 extra_info_db["latin-1-path-encoding"]["last_scmid"]
142 assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
144 assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
143 extra_info_db["master"]["last_scmid"]
145 extra_info_db["master"]["last_scmid"]
144
146
145 del_revs = [
147 del_revs = [
146 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
148 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
147 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
149 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
148 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
150 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
149 "deff712f05a90d96edbd70facc47d944be5897e3",
151 "deff712f05a90d96edbd70facc47d944be5897e3",
150 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
152 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
151 "7e61ac704deecde634b51e59daa8110435dcb3da",
153 "7e61ac704deecde634b51e59daa8110435dcb3da",
152 ]
154 ]
153 @repository.changesets.each do |rev|
155 @repository.changesets.each do |rev|
154 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
156 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
155 end
157 end
156 @repository.reload
158 @repository.reload
157 cs1 = @repository.changesets
159 cs1 = @repository.changesets
158 assert_equal 15, cs1.count
160 assert_equal 15, cs1.count
159 h = @repository.extra_info.dup
161 h = @repository.extra_info.dup
160 h["branches"]["master"]["last_scmid"] =
162 h["branches"]["master"]["last_scmid"] =
161 "abcd1234efgh"
163 "abcd1234efgh"
162 @repository.merge_extra_info(h)
164 @repository.merge_extra_info(h)
163 @repository.save
165 @repository.save
164 @repository.reload
166 @repository.reload
165 extra_info_db_1 = @repository.extra_info["branches"]
167 extra_info_db_1 = @repository.extra_info["branches"]
166 assert_equal "abcd1234efgh",
168 assert_equal "abcd1234efgh",
167 extra_info_db_1["master"]["last_scmid"]
169 extra_info_db_1["master"]["last_scmid"]
168
170
169 @repository.fetch_changesets
171 @repository.fetch_changesets
170 assert_equal 15, @repository.changesets.count
172 assert_equal 15, @repository.changesets.count
171 end
173 end
172
174
173 def test_db_consistent_ordering_init
175 def test_db_consistent_ordering_init
174 assert_nil @repository.extra_info
176 assert_nil @repository.extra_info
175 @repository.fetch_changesets
177 @repository.fetch_changesets
176 @repository.reload
178 @repository.reload
177 assert_equal 1, @repository.extra_info["db_consistent"]["ordering"]
179 assert_equal 1, @repository.extra_info["db_consistent"]["ordering"]
178 end
180 end
179
181
180 def test_db_consistent_ordering_before_1_2
182 def test_db_consistent_ordering_before_1_2
181 assert_nil @repository.extra_info
183 assert_nil @repository.extra_info
182 @repository.fetch_changesets
184 @repository.fetch_changesets
183 @repository.reload
185 @repository.reload
184 assert_equal 21, @repository.changesets.count
186 assert_equal 21, @repository.changesets.count
185 assert_not_nil @repository.extra_info
187 assert_not_nil @repository.extra_info
186 @repository.write_attribute(:extra_info, nil)
188 @repository.write_attribute(:extra_info, nil)
187 @repository.save
189 @repository.save
188 assert_nil @repository.extra_info
190 assert_nil @repository.extra_info
189 assert_equal 21, @repository.changesets.count
191 assert_equal 21, @repository.changesets.count
190 @repository.fetch_changesets
192 @repository.fetch_changesets
191 @repository.reload
193 @repository.reload
192 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
194 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
193
195
194 del_revs = [
196 del_revs = [
195 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
197 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
196 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
198 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
197 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
199 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
198 "deff712f05a90d96edbd70facc47d944be5897e3",
200 "deff712f05a90d96edbd70facc47d944be5897e3",
199 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
201 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
200 "7e61ac704deecde634b51e59daa8110435dcb3da",
202 "7e61ac704deecde634b51e59daa8110435dcb3da",
201 ]
203 ]
202 @repository.changesets.each do |rev|
204 @repository.changesets.each do |rev|
203 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
205 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
204 end
206 end
205 @repository.reload
207 @repository.reload
206 cs1 = @repository.changesets
208 cs1 = @repository.changesets
207 assert_equal 15, cs1.count
209 assert_equal 15, cs1.count
208 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
210 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
209 h = @repository.extra_info.dup
211 h = @repository.extra_info.dup
210 h["branches"]["master"]["last_scmid"] =
212 h["branches"]["master"]["last_scmid"] =
211 "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
213 "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
212 @repository.merge_extra_info(h)
214 @repository.merge_extra_info(h)
213 @repository.save
215 @repository.save
214 @repository.reload
216 @repository.reload
215 extra_info_db_1 = @repository.extra_info["branches"]
217 extra_info_db_1 = @repository.extra_info["branches"]
216 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8",
218 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8",
217 extra_info_db_1["master"]["last_scmid"]
219 extra_info_db_1["master"]["last_scmid"]
218
220
219 @repository.fetch_changesets
221 @repository.fetch_changesets
220 assert_equal 21, @repository.changesets.count
222 assert_equal 21, @repository.changesets.count
221 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
223 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
222 end
224 end
223
225
224 def test_latest_changesets
226 def test_latest_changesets
225 @repository.fetch_changesets
227 @repository.fetch_changesets
226 @repository.reload
228 @repository.reload
227 # with limit
229 # with limit
228 changesets = @repository.latest_changesets('', nil, 2)
230 changesets = @repository.latest_changesets('', nil, 2)
229 assert_equal 2, changesets.size
231 assert_equal 2, changesets.size
230
232
231 # with path
233 # with path
232 changesets = @repository.latest_changesets('images', nil)
234 changesets = @repository.latest_changesets('images', nil)
233 assert_equal [
235 assert_equal [
234 'deff712f05a90d96edbd70facc47d944be5897e3',
236 'deff712f05a90d96edbd70facc47d944be5897e3',
235 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
237 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
236 '7234cb2750b63f47bff735edc50a1c0a433c2518',
238 '7234cb2750b63f47bff735edc50a1c0a433c2518',
237 ], changesets.collect(&:revision)
239 ], changesets.collect(&:revision)
238
240
239 changesets = @repository.latest_changesets('README', nil)
241 changesets = @repository.latest_changesets('README', nil)
240 assert_equal [
242 assert_equal [
241 '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf',
243 '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf',
242 '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8',
244 '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8',
243 '713f4944648826f558cf548222f813dabe7cbb04',
245 '713f4944648826f558cf548222f813dabe7cbb04',
244 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
246 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
245 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
247 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
246 '7234cb2750b63f47bff735edc50a1c0a433c2518',
248 '7234cb2750b63f47bff735edc50a1c0a433c2518',
247 ], changesets.collect(&:revision)
249 ], changesets.collect(&:revision)
248
250
249 # with path, revision and limit
251 # with path, revision and limit
250 changesets = @repository.latest_changesets('images', '899a15dba')
252 changesets = @repository.latest_changesets('images', '899a15dba')
251 assert_equal [
253 assert_equal [
252 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
254 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
253 '7234cb2750b63f47bff735edc50a1c0a433c2518',
255 '7234cb2750b63f47bff735edc50a1c0a433c2518',
254 ], changesets.collect(&:revision)
256 ], changesets.collect(&:revision)
255
257
256 changesets = @repository.latest_changesets('images', '899a15dba', 1)
258 changesets = @repository.latest_changesets('images', '899a15dba', 1)
257 assert_equal [
259 assert_equal [
258 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
260 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
259 ], changesets.collect(&:revision)
261 ], changesets.collect(&:revision)
260
262
261 changesets = @repository.latest_changesets('README', '899a15dba')
263 changesets = @repository.latest_changesets('README', '899a15dba')
262 assert_equal [
264 assert_equal [
263 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
265 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
264 '7234cb2750b63f47bff735edc50a1c0a433c2518',
266 '7234cb2750b63f47bff735edc50a1c0a433c2518',
265 ], changesets.collect(&:revision)
267 ], changesets.collect(&:revision)
266
268
267 changesets = @repository.latest_changesets('README', '899a15dba', 1)
269 changesets = @repository.latest_changesets('README', '899a15dba', 1)
268 assert_equal [
270 assert_equal [
269 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
271 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
270 ], changesets.collect(&:revision)
272 ], changesets.collect(&:revision)
271
273
272 # with path, tag and limit
274 # with path, tag and limit
273 changesets = @repository.latest_changesets('images', 'tag01.annotated')
275 changesets = @repository.latest_changesets('images', 'tag01.annotated')
274 assert_equal [
276 assert_equal [
275 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
277 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
276 '7234cb2750b63f47bff735edc50a1c0a433c2518',
278 '7234cb2750b63f47bff735edc50a1c0a433c2518',
277 ], changesets.collect(&:revision)
279 ], changesets.collect(&:revision)
278
280
279 changesets = @repository.latest_changesets('images', 'tag01.annotated', 1)
281 changesets = @repository.latest_changesets('images', 'tag01.annotated', 1)
280 assert_equal [
282 assert_equal [
281 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
283 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
282 ], changesets.collect(&:revision)
284 ], changesets.collect(&:revision)
283
285
284 changesets = @repository.latest_changesets('README', 'tag01.annotated')
286 changesets = @repository.latest_changesets('README', 'tag01.annotated')
285 assert_equal [
287 assert_equal [
286 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
288 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
287 '7234cb2750b63f47bff735edc50a1c0a433c2518',
289 '7234cb2750b63f47bff735edc50a1c0a433c2518',
288 ], changesets.collect(&:revision)
290 ], changesets.collect(&:revision)
289
291
290 changesets = @repository.latest_changesets('README', 'tag01.annotated', 1)
292 changesets = @repository.latest_changesets('README', 'tag01.annotated', 1)
291 assert_equal [
293 assert_equal [
292 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
294 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
293 ], changesets.collect(&:revision)
295 ], changesets.collect(&:revision)
294
296
295 # with path, branch and limit
297 # with path, branch and limit
296 changesets = @repository.latest_changesets('images', 'test_branch')
298 changesets = @repository.latest_changesets('images', 'test_branch')
297 assert_equal [
299 assert_equal [
298 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
300 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
299 '7234cb2750b63f47bff735edc50a1c0a433c2518',
301 '7234cb2750b63f47bff735edc50a1c0a433c2518',
300 ], changesets.collect(&:revision)
302 ], changesets.collect(&:revision)
301
303
302 changesets = @repository.latest_changesets('images', 'test_branch', 1)
304 changesets = @repository.latest_changesets('images', 'test_branch', 1)
303 assert_equal [
305 assert_equal [
304 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
306 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
305 ], changesets.collect(&:revision)
307 ], changesets.collect(&:revision)
306
308
307 changesets = @repository.latest_changesets('README', 'test_branch')
309 changesets = @repository.latest_changesets('README', 'test_branch')
308 assert_equal [
310 assert_equal [
309 '713f4944648826f558cf548222f813dabe7cbb04',
311 '713f4944648826f558cf548222f813dabe7cbb04',
310 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
312 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
311 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
313 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
312 '7234cb2750b63f47bff735edc50a1c0a433c2518',
314 '7234cb2750b63f47bff735edc50a1c0a433c2518',
313 ], changesets.collect(&:revision)
315 ], changesets.collect(&:revision)
314
316
315 changesets = @repository.latest_changesets('README', 'test_branch', 2)
317 changesets = @repository.latest_changesets('README', 'test_branch', 2)
316 assert_equal [
318 assert_equal [
317 '713f4944648826f558cf548222f813dabe7cbb04',
319 '713f4944648826f558cf548222f813dabe7cbb04',
318 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
320 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
319 ], changesets.collect(&:revision)
321 ], changesets.collect(&:revision)
320
322
321 if JRUBY_SKIP
323 if JRUBY_SKIP
322 puts JRUBY_SKIP_STR
324 puts JRUBY_SKIP_STR
323 else
325 else
324 # latin-1 encoding path
326 # latin-1 encoding path
325 changesets = @repository.latest_changesets(
327 changesets = @repository.latest_changesets(
326 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89')
328 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89')
327 assert_equal [
329 assert_equal [
328 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
330 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
329 '4fc55c43bf3d3dc2efb66145365ddc17639ce81e',
331 '4fc55c43bf3d3dc2efb66145365ddc17639ce81e',
330 ], changesets.collect(&:revision)
332 ], changesets.collect(&:revision)
331
333
332 changesets = @repository.latest_changesets(
334 changesets = @repository.latest_changesets(
333 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1)
335 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1)
334 assert_equal [
336 assert_equal [
335 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
337 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
336 ], changesets.collect(&:revision)
338 ], changesets.collect(&:revision)
337 end
339 end
338 end
340 end
339
341
340 def test_latest_changesets_latin_1_dir
342 def test_latest_changesets_latin_1_dir
341 if WINDOWS_PASS
343 if WINDOWS_PASS
342 #
344 #
343 elsif JRUBY_SKIP
345 elsif JRUBY_SKIP
344 puts JRUBY_SKIP_STR
346 puts JRUBY_SKIP_STR
345 else
347 else
346 @repository.fetch_changesets
348 @repository.fetch_changesets
347 @repository.reload
349 @repository.reload
348 changesets = @repository.latest_changesets(
350 changesets = @repository.latest_changesets(
349 "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed')
351 "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed')
350 assert_equal [
352 assert_equal [
351 '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127',
353 '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127',
352 ], changesets.collect(&:revision)
354 ], changesets.collect(&:revision)
353 end
355 end
354 end
356 end
355
357
356 def test_find_changeset_by_name
358 def test_find_changeset_by_name
357 @repository.fetch_changesets
359 @repository.fetch_changesets
358 @repository.reload
360 @repository.reload
359 ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r|
361 ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r|
360 assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518',
362 assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518',
361 @repository.find_changeset_by_name(r).revision
363 @repository.find_changeset_by_name(r).revision
362 end
364 end
363 end
365 end
364
366
365 def test_find_changeset_by_empty_name
367 def test_find_changeset_by_empty_name
366 @repository.fetch_changesets
368 @repository.fetch_changesets
367 @repository.reload
369 @repository.reload
368 ['', ' ', nil].each do |r|
370 ['', ' ', nil].each do |r|
369 assert_nil @repository.find_changeset_by_name(r)
371 assert_nil @repository.find_changeset_by_name(r)
370 end
372 end
371 end
373 end
372
374
373 def test_identifier
375 def test_identifier
374 @repository.fetch_changesets
376 @repository.fetch_changesets
375 @repository.reload
377 @repository.reload
376 c = @repository.changesets.find_by_revision(
378 c = @repository.changesets.find_by_revision(
377 '7234cb2750b63f47bff735edc50a1c0a433c2518')
379 '7234cb2750b63f47bff735edc50a1c0a433c2518')
378 assert_equal c.scmid, c.identifier
380 assert_equal c.scmid, c.identifier
379 end
381 end
380
382
381 def test_format_identifier
383 def test_format_identifier
382 @repository.fetch_changesets
384 @repository.fetch_changesets
383 @repository.reload
385 @repository.reload
384 c = @repository.changesets.find_by_revision(
386 c = @repository.changesets.find_by_revision(
385 '7234cb2750b63f47bff735edc50a1c0a433c2518')
387 '7234cb2750b63f47bff735edc50a1c0a433c2518')
386 assert_equal '7234cb27', c.format_identifier
388 assert_equal '7234cb27', c.format_identifier
387 end
389 end
388
390
389 def test_activities
391 def test_activities
390 c = Changeset.new(:repository => @repository,
392 c = Changeset.new(:repository => @repository,
391 :committed_on => Time.now,
393 :committed_on => Time.now,
392 :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
394 :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
393 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
395 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
394 :comments => 'test')
396 :comments => 'test')
395 assert c.event_title.include?('abc7234c:')
397 assert c.event_title.include?('abc7234c:')
396 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev]
398 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev]
397 end
399 end
398
400
399 def test_log_utf8
401 def test_log_utf8
400 @repository.fetch_changesets
402 @repository.fetch_changesets
401 @repository.reload
403 @repository.reload
402 str_felix_hex = FELIX_HEX.dup
404 str_felix_hex = FELIX_HEX.dup
403 if str_felix_hex.respond_to?(:force_encoding)
405 if str_felix_hex.respond_to?(:force_encoding)
404 str_felix_hex.force_encoding('UTF-8')
406 str_felix_hex.force_encoding('UTF-8')
405 end
407 end
406 c = @repository.changesets.find_by_revision(
408 c = @repository.changesets.find_by_revision(
407 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b')
409 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b')
408 assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer
410 assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer
409 end
411 end
410
412
411 def test_previous
413 def test_previous
412 @repository.fetch_changesets
414 @repository.fetch_changesets
413 @repository.reload
415 @repository.reload
414 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
416 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
415 changeset = @repository.find_changeset_by_name(r1)
417 changeset = @repository.find_changeset_by_name(r1)
416 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
418 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
417 assert_equal @repository.find_changeset_by_name(r2), changeset.previous
419 assert_equal @repository.find_changeset_by_name(r2), changeset.previous
418 end
420 end
419 end
421 end
420 end
422 end
421
423
422 def test_previous_nil
424 def test_previous_nil
423 @repository.fetch_changesets
425 @repository.fetch_changesets
424 @repository.reload
426 @repository.reload
425 %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb2|.each do |r1|
427 %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb2|.each do |r1|
426 changeset = @repository.find_changeset_by_name(r1)
428 changeset = @repository.find_changeset_by_name(r1)
427 assert_nil changeset.previous
429 assert_nil changeset.previous
428 end
430 end
429 end
431 end
430
432
431 def test_next
433 def test_next
432 @repository.fetch_changesets
434 @repository.fetch_changesets
433 @repository.reload
435 @repository.reload
434 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
436 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
435 changeset = @repository.find_changeset_by_name(r2)
437 changeset = @repository.find_changeset_by_name(r2)
436 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
438 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
437 assert_equal @repository.find_changeset_by_name(r1), changeset.next
439 assert_equal @repository.find_changeset_by_name(r1), changeset.next
438 end
440 end
439 end
441 end
440 end
442 end
441
443
442 def test_next_nil
444 def test_next_nil
443 @repository.fetch_changesets
445 @repository.fetch_changesets
444 @repository.reload
446 @repository.reload
445 %w|67e7792ce20ccae2e4bb73eed09bb397819c8834 67e7792ce20cca|.each do |r1|
447 %w|67e7792ce20ccae2e4bb73eed09bb397819c8834 67e7792ce20cca|.each do |r1|
446 changeset = @repository.find_changeset_by_name(r1)
448 changeset = @repository.find_changeset_by_name(r1)
447 assert_nil changeset.next
449 assert_nil changeset.next
448 end
450 end
449 end
451 end
450 else
452 else
451 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
453 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
452 def test_fake; assert true end
454 def test_fake; assert true end
453 end
455 end
454 end
456 end
General Comments 0
You need to be logged in to leave comments. Login now