You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repository_git_test.rb 21KB

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