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