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