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