capillary 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capillary (0.2.1)
4
+ capillary (0.2.2)
5
5
  json (~> 1.5.1)
6
6
 
7
7
  GEM
@@ -27,7 +27,6 @@ module Capillary
27
27
  @branches = []
28
28
  @seq_ids = {}
29
29
  @commit_positions = {}
30
- @relationships = {}
31
30
  end
32
31
 
33
32
  def <<(commit)
@@ -81,14 +80,6 @@ module Capillary
81
80
  @commit_positions[commit.id] = [col, branches[col].length]
82
81
  end
83
82
 
84
- if branches[col].length > 0
85
- pid = branches[col].last.commit.id
86
- relationship = "#{commit.id}:#{pid}"
87
- return if @relationships[relationship]
88
- @relationships[relationship] = true
89
- end
90
-
91
- parent = commit.parent_id ? " (#{commit.parent_id[0...7]})" : ""
92
83
  branches[col] << commit
93
84
  end
94
85
  end
@@ -17,5 +17,5 @@
17
17
  #++
18
18
 
19
19
  module Capillary
20
- VERSION = "0.2.2"
20
+ VERSION = "0.2.3"
21
21
  end
@@ -27,12 +27,15 @@ class LogParserTest < MiniTest::Spec
27
27
  end
28
28
 
29
29
  def load_fixture(fixture)
30
- fixtures = fixture(fixture).split("\n")
30
+ parse_log(fixture(fixture))
31
+ end
32
+
33
+ def parse_log(log)
31
34
  @log_parser = Capillary::LogParser.new
32
35
  @lines = []
33
36
 
34
- fixtures.reject { |f| f.strip == "" }.each do |fixture|
35
- @lines << Capillary::Commit.parse(fixture)
37
+ log.split("\n").reject { |f| f.strip == "" }.each do |log|
38
+ @lines << Capillary::Commit.parse(log)
36
39
  @log_parser << @lines.last
37
40
  end
38
41
  end
@@ -172,14 +175,7 @@ class LogParserTest < MiniTest::Spec
172
175
  # | | |
173
176
  context "Complex graph merged with --no-ff" do
174
177
  setup do
175
- fixtures = fixture("complex_graph_no_ff.txt").split("\n")
176
- @log_parser = Capillary::LogParser.new
177
- @lines = []
178
-
179
- fixtures.reject { |f| f.strip == "" }.each do |fixture|
180
- @lines << Capillary::Commit.parse(fixture)
181
- @log_parser << @lines.last
182
- end
178
+ load_fixture("complex_graph_no_ff.txt")
183
179
  end
184
180
 
185
181
  should "have four branches" do
@@ -250,14 +246,7 @@ class LogParserTest < MiniTest::Spec
250
246
  # |
251
247
  context "Complex graph merged with --no-ff" do
252
248
  setup do
253
- fixtures = fixture("complex_graph.txt").split("\n")
254
- @log_parser = Capillary::LogParser.new
255
- @lines = []
256
-
257
- fixtures.reject { |f| f.strip == "" }.each do |fixture|
258
- @lines << Capillary::Commit.parse(fixture)
259
- @log_parser << @lines.last
260
- end
249
+ load_fixture("complex_graph.txt")
261
250
  end
262
251
 
263
252
  should "have three branches" do
@@ -273,7 +262,7 @@ class LogParserTest < MiniTest::Spec
273
262
  end
274
263
 
275
264
  should "have three commits in the third branch" do
276
- assert_equal 3, @log_parser.branches[2].size
265
+ assert_equal 4, @log_parser.branches[2].size
277
266
  end
278
267
 
279
268
  should "not create more seq_id's than there are commits" do
@@ -282,7 +271,7 @@ class LogParserTest < MiniTest::Spec
282
271
 
283
272
  should "not represent same commit under different seq_id's" do
284
273
  assert_equal [2, 4, 5, 6, 7, 9, 10], @log_parser.branches[1].collect { |c| c.seq_id }
285
- assert_equal [5, 8, 9], @log_parser.branches[2].collect { |c| c.seq_id }
274
+ assert_equal [5, 8, 9, 10], @log_parser.branches[2].collect { |c| c.seq_id }
286
275
  end
287
276
  end
288
277
 
@@ -308,14 +297,7 @@ class LogParserTest < MiniTest::Spec
308
297
  # | |
309
298
  context "Parsing log --graph output" do
310
299
  setup do
311
- fixtures = fixture("log_graph.txt").split("\n")
312
- @log_parser = Capillary::LogParser.new
313
- @lines = []
314
-
315
- fixtures.reject { |f| f.strip == "" }.each do |fixture|
316
- @lines << Capillary::Commit.parse(fixture)
317
- @log_parser << @lines.last
318
- end
300
+ load_fixture("log_graph.txt")
319
301
  end
320
302
 
321
303
  should "have two branches" do
@@ -365,39 +347,32 @@ class LogParserTest < MiniTest::Spec
365
347
  # |
366
348
  context "Two branches forked from same commit" do
367
349
  setup do
368
- fixtures = fixture("double_fork.txt").split("\n")
369
- @log_parser = Capillary::LogParser.new
370
- @lines = []
371
-
372
- fixtures.reject { |f| f.strip == "" }.each do |fixture|
373
- @lines << Capillary::Commit.parse(fixture)
374
- @log_parser << @lines.last
375
- end
350
+ load_fixture("double_fork.txt")
376
351
  end
377
352
 
378
353
  should "have three branches" do
379
- assert_equal 3, @log_parser.branches.length
354
+ assert_equal 3, branches.length
380
355
  end
381
356
 
382
- should "have the six commits in the first branch" do
357
+ should "have six commits in the first branch" do
383
358
  commits = @log_parser.branches[0].collect { |c| c.id[0...7] }
384
359
 
385
360
  assert_equal 6, commits.length
386
361
  assert_equal %w[0f54800 5bdf304 2477a17 ea4d6ce fdc39f6 9002b5b], commits
387
362
  end
388
363
 
389
- should "have the ten commits in the second branch" do
364
+ should "have eleven commits in the second branch" do
390
365
  commits = @log_parser.branches[1].collect { |c| c.id[0...7] }
391
366
 
392
- assert_equal 10, commits.length
393
- assert_equal %w[2477a17 13c727b bd73540 6fb3997 9266f54 a5f9deb 1551dfe 16d2ac1 1e69972 fdc39f6], commits
367
+ assert_equal 11, commits.length
368
+ assert_equal %w[2477a17 13c727b bd73540 6fb3997 9266f54 a5f9deb 1551dfe 16d2ac1 1e69972 fdc39f6 9002b5b], commits
394
369
  end
395
370
 
396
- should "have the eight commits in the third branch" do
371
+ should "have nine commits in the third branch" do
397
372
  commits = @log_parser.branches[2].collect { |c| c.id[0...7] }
398
373
 
399
- assert_equal 8, commits.length
400
- assert_equal %w[ea4d6ce 74510fd 09b2486 4f0eaf7 fe57cfc cbdfa12 81febec fdc39f6], commits
374
+ assert_equal 9, commits.length
375
+ assert_equal %w[ea4d6ce 74510fd 09b2486 4f0eaf7 fe57cfc cbdfa12 81febec fdc39f6 9002b5b], commits
401
376
  end
402
377
  end
403
378
 
@@ -407,13 +382,10 @@ class LogParserTest < MiniTest::Spec
407
382
  # | |
408
383
  context "Two dangling branches" do
409
384
  setup do
410
- log = <<-GIT
385
+ parse_log <<-GIT
411
386
  ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
412
387
  c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60f8§Tue May 10 12:41:19 2011 +0200§christian@gitorious.org§§Merge commit 'refs/merge-requests/2230' of gitorious.org:gitorious/mainline into merge-requests/2230§
413
388
  GIT
414
-
415
- @log_parser = Capillary::LogParser.new
416
- log.split("\n").each { |l| @log_parser << l }
417
389
  end
418
390
 
419
391
  should "have two branches" do
@@ -437,14 +409,11 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
437
409
  # | |
438
410
  context "Two dangling branches with leading commit" do
439
411
  setup do
440
- log = <<-GIT
412
+ parse_log <<-GIT
441
413
  1f2b8a4e3f61ffedf9908e28b280de8c6bf38a16§ca2d07e0172565c9e0f18d41e49b70d7d75fced6§Tue May 10 13:04:10 2011 +0200§christian@gitorious.org§§Some commit§
442
414
  ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
443
415
  c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60f8§Tue May 10 12:41:19 2011 +0200§christian@gitorious.org§§Merge commit 'refs/merge-requests/2230' of gitorious.org:gitorious/mainline into merge-requests/2230§
444
416
  GIT
445
-
446
- @log_parser = Capillary::LogParser.new
447
- log.split("\n").each { |l| @log_parser << l }
448
417
  end
449
418
 
450
419
  should "have two branches" do
@@ -468,14 +437,11 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
468
437
  # | | |
469
438
  context "Three dangling branches" do
470
439
  setup do
471
- log = <<-GIT
440
+ parse_log <<-GIT
472
441
  1f2b8a4e3f61ffedf9908e28b280de8c6bf38a16§ca2d07e0172565c9e0f18d41e49b70d7d75fced6 275932ab0995a11fcebeb0af7f19a7b8df5dea3f§Tue May 10 13:04:10 2011 +0200§christian@gitorious.org§§Some commit§
473
442
  ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
474
443
  c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60f8§Tue May 10 12:41:19 2011 +0200§christian@gitorious.org§§Merge commit 'refs/merge-requests/2230' of gitorious.org:gitorious/mainline into merge-requests/2230§
475
444
  GIT
476
-
477
- @log_parser = Capillary::LogParser.new
478
- log.split("\n").each { |l| @log_parser << l }
479
445
  end
480
446
 
481
447
  should "have three branches" do
@@ -508,7 +474,7 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
508
474
  # | | |
509
475
  context "Three dangling branches with closed branch" do
510
476
  setup do
511
- log = <<-GIT
477
+ parse_log <<-GIT
512
478
  0000000000000000000000000000000000000000§1111111111111111111111111111111111111111 3333333333333333333333333333333333333333§Tue May 10 13:00:00 2011 +0200§christian@gitorious.org§§Message§
513
479
  1111111111111111111111111111111111111111§4444444444444444444444444444444444444444 2222222222222222222222222222222222222222§Tue May 10 12:00:00 2011 +0200§christian@gitorious.org§§Message§
514
480
  2222222222222222222222222222222222222222§4444444444444444444444444444444444444444§Tue May 10 11:00:00 2011 +0200§christian@gitorious.org§§Message§
@@ -516,9 +482,6 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
516
482
  4444444444444444444444444444444444444444§7777777777777777777777777777777777777777 5555555555555555555555555555555555555555§Tue May 10 09:00:00 2011 +0200§christian@gitorious.org§§Message§
517
483
  5555555555555555555555555555555555555555§8888888888888888888888888888888888888888§Tue May 10 08:00:00 2011 +0200§christian@gitorious.org§§Message§
518
484
  GIT
519
-
520
- @log_parser = Capillary::LogParser.new
521
- log.split("\n").each { |l| @log_parser << l }
522
485
  end
523
486
 
524
487
  should "have four branches" do
@@ -546,29 +509,104 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
546
509
  # |\
547
510
  # | 0
548
511
  # | |\
549
- # | | 0
550
- # |/ |
551
- # 0 |
552
- # |\ |
553
- # | 0 |
554
- # | | |
555
- # | 0 |
556
- # | | |
557
- # | 0-|
558
- # | | |\
559
- # | | | 0
560
- # |/ | |
561
- # 0 | |
562
- # |\ | |
563
- # | 0 | |
564
- # | | | |
512
+ context "two commits with two parents" do
513
+ setup do
514
+ parse_log <<-GIT
515
+ ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
516
+ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60f8 c1e52fba9e7c88f1146bb6df1f8b58dff006f45e§Tue May 10 12:41:19 2011 +0200§christian@gitorious.org§§Merge commit 'refs/merge-requests/2230' of gitorious.org:gitorious/mainline into merge-requests/2230§
517
+ GIT
518
+ end
519
+
520
+ should "have three branches" do
521
+ assert_equal 3, branches.length
522
+ end
523
+
524
+ should "have one commit in the first branch" do
525
+ assert_equal %w[ca2d07e], commits_for_branch(0)
526
+ end
527
+
528
+ should "have two commits in the second branch" do
529
+ assert_equal %w[ca2d07e c4e7446], commits_for_branch(1)
530
+ end
531
+
532
+ should "have three commits in the third branch" do
533
+ assert_equal %w[c4e7446], commits_for_branch(2)
534
+ end
535
+ end
536
+
537
+ # 1f2b8a4 # 0
538
+ # | \ # |\
539
+ # | a2f271b # | 0
540
+ # | | \ # | |\
541
+ # | | 3ec0ec6 # | | 0
542
+ # | / | # |/ |
543
+ # ca2d07e | # 0 |
544
+ # | \ | # |\ |
545
+ # | c4e7446-|- # | 0-|
546
+ # | | | \ # | | |\
547
+ context "Three branches from four dangling branches" do
548
+ setup do
549
+ parse_log <<-GIT
550
+ 1f2b8a4e3f61ffedf9908e28b280de8c6bf38a16§ca2d07e0172565c9e0f18d41e49b70d7d75fced6 a2f271b1aa55e52ba848779c62a6fa02cbc5ea0c§Tue May 10 13:04:10 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/147'§
551
+ a2f271b1aa55e52ba848779c62a6fa02cbc5ea0c§ca2d07e0172565c9e0f18d41e49b70d7d75fced6 3ec0ec68ac9ae2db3f222dfe1842cd2c6812cf97§Tue May 10 12:50:35 2011 +0200§christian@gitorious.org§§Merge commit 'refs/merge-requests/147' of gitorious.org:gitorious/mainline into merge-requests/147§
552
+ 3ec0ec68ac9ae2db3f222dfe1842cd2c6812cf97§0685c52dd27dba8eaa6ec6f6bfacf014d37a6a1b§Tue Apr 12 10:04:20 2011 +1000§openid@obfusc8.org§§Bug: Do not redirect_back_or_default on new OpenID§
553
+ ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
554
+ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60f8 c1e52fba9e7c88f1146bb6df1f8b58dff006f45e§Tue May 10 12:41:19 2011 +0200§christian@gitorious.org§§Merge commit 'refs/merge-requests/2230' of gitorious.org:gitorious/mainline into merge-requests/2230§
555
+ GIT
556
+ end
557
+
558
+ should "have five branches" do
559
+ assert_equal 5, branches.length
560
+ end
561
+
562
+ should "have two commits in first branch" do
563
+ assert_equal %w[1f2b8a4 ca2d07e], commits_for_branch(0)
564
+ end
565
+
566
+ should "have three commits in second branch" do
567
+ assert_equal %w[1f2b8a4 a2f271b ca2d07e], commits_for_branch(1)
568
+ end
569
+
570
+ should "have two commits in third branch" do
571
+ assert_equal %w[a2f271b 3ec0ec6], commits_for_branch(2)
572
+ end
573
+
574
+ should "have two commits in fourth branch" do
575
+ assert_equal %w[ca2d07e c4e7446], commits_for_branch(3)
576
+ end
577
+
578
+ should "have one commit in fifth branch" do
579
+ assert_equal %w[c4e7446], commits_for_branch(4)
580
+ end
581
+ end
582
+
583
+ # 44c5c1d
584
+ # | \
585
+ # | e81d019
586
+ # | | \
587
+ # | | bbbd502
588
+ # | / |
589
+ # 1f2b8a4 |
590
+ # | \ |
591
+ # | 275932a |
592
+ # | | |
593
+ # | 7487183 |
594
+ # | | |
595
+ # | a2f271b-|------
596
+ # | | | \
597
+ # | | | 3ec0ec6
598
+ # | / | |
599
+ # ca2d07e | |
600
+ # | \ | |
601
+ # | c4e7446-|-------|------
602
+ # | | | | \
565
603
  context "Four dangling branches" do
566
604
  setup do
567
605
  load_fixture("4x_dangling_branches.txt")
568
606
  end
569
607
 
570
608
  should "have seven branches" do
571
- assert_equal 6, branches.length
609
+ assert_equal 7, branches.length
572
610
  end
573
611
 
574
612
  should "have 3 commits in the first branch" do
@@ -576,7 +614,7 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
576
614
  end
577
615
 
578
616
  should "have 3 commits in the second branch" do
579
- assert_equal %w[44c5c1d e81d019 1f2b8a4], commits_for_branch(1)
617
+ assert_equal %w[44c5c1d e81d019 1f2b8a4 ca2d07e], commits_for_branch(1)
580
618
  end
581
619
 
582
620
  should "have 2 commits in the third branch" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capillary
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marius Mathiesen
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-23 00:00:00 +02:00
19
+ date: 2011-08-24 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency