capillary 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ test/reports
2
+ coverage
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+ gem "ci_reporter"
5
+ gem "rcov", :platforms => :ruby_18
6
+ gem "simplecov", :platforms => :ruby_19
7
+ gem "simplecov-rcov", :platforms => :ruby_19
@@ -1,23 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capillary (1.0.3)
4
+ capillary (1.0.4)
5
+ htmlentities
5
6
  json (~> 1.5)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
11
+ builder (3.0.4)
12
+ ci_reporter (1.9.0)
13
+ builder (>= 2.1.2)
14
+ htmlentities (4.3.1)
10
15
  json (1.8.0)
11
- mini_shoulda (0.3.0)
12
- minitest (~> 2.1.0)
13
16
  minitest (2.1.0)
17
+ multi_json (1.7.7)
14
18
  rake (0.9.6)
19
+ rcov (1.0.0)
20
+ simplecov (0.7.1)
21
+ multi_json (~> 1.0)
22
+ simplecov-html (~> 0.7.1)
23
+ simplecov-html (0.7.1)
24
+ simplecov-rcov (0.2.3)
25
+ simplecov (>= 0.4.1)
15
26
 
16
27
  PLATFORMS
17
28
  ruby
18
29
 
19
30
  DEPENDENCIES
20
31
  capillary!
21
- mini_shoulda (~> 0.3)
32
+ ci_reporter
22
33
  minitest (~> 2.0)
23
34
  rake
35
+ rcov
36
+ simplecov
37
+ simplecov-rcov
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require "rake/testtask"
2
+ require "ci/reporter/rake/minitest"
2
3
 
3
4
  Rake::TestTask.new("test") do |test|
4
5
  test.libs << "lib"
@@ -7,4 +8,26 @@ Rake::TestTask.new("test") do |test|
7
8
  test.verbose = true
8
9
  end
9
10
 
11
+ if RUBY_VERSION < "1.9"
12
+ require "rcov/rcovtask"
13
+ Rcov::RcovTask.new do |t|
14
+ t.libs << "test"
15
+ t.test_files = FileList["test/**/*_test.rb"]
16
+ t.rcov_opts += %w{--exclude gems}
17
+ end
18
+ else
19
+ # Compatibility "rcov" task
20
+ # This task moves the simplecov-rcov files into the parent "coverage"
21
+ # directory. This more or less matches what happens when using the rcov gem
22
+ # on Ruby 1.8. This compatibility task allows us to use the same Jenkins
23
+ # configuration on Ruby 1.8 and Ruby > 1.9.
24
+ task :rcov => :test do
25
+ puts "Moving simplecov-rcov report to " + File.expand_path( "#{File.dirname(__FILE__)}/coverage" )
26
+ FileUtils.mv("coverage/rcov", ".", :force => true)
27
+ FileUtils.mv("coverage", "simplecov-coverage", :force => true)
28
+ FileUtils.mv("rcov", "coverage", :force => true)
29
+ FileUtils.mv("simplecov-coverage", "coverage/simplecov", :force => true)
30
+ end
31
+ end
32
+
10
33
  task :default => :test
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
14
14
  s.rubyforge_project = "capillary"
15
15
 
16
16
  s.add_dependency "json", "~> 1.5"
17
+ s.add_dependency "htmlentities"
17
18
 
18
19
  s.add_development_dependency "minitest", "~> 2.0"
19
- s.add_development_dependency "mini_shoulda", "~> 0.3"
20
20
  s.add_development_dependency "rake"
21
21
 
22
22
  s.files = `git ls-files`.split("\n")
@@ -17,6 +17,7 @@
17
17
  #++
18
18
  require "json"
19
19
  require "time"
20
+ require "htmlentities"
20
21
  require "capillary/ref_collection"
21
22
 
22
23
  module Capillary
@@ -35,7 +36,7 @@ module Capillary
35
36
  git_line = git_line.gsub(/^[^a-f0-9]+/, "")
36
37
  return nil if git_line == ""
37
38
 
38
- parts = git_line.split(LOG_SEPARATOR)
39
+ parts = git_line.force_encoding('utf-8').split(LOG_SEPARATOR)
39
40
  result = new
40
41
  result.id = parts[0]
41
42
  result.parent_ids = parts[1].split(" ")
@@ -66,7 +67,7 @@ module Capillary
66
67
  end
67
68
 
68
69
  def message
69
- @message.gsub(/[^A-Za-z0-9\s\'\n\.,\/]/,"")
70
+ HTMLEntities.new.encode(@message)
70
71
  end
71
72
  end
72
73
  end
@@ -35,7 +35,7 @@ module Capillary
35
35
 
36
36
  def parse(ref)
37
37
  return if ref.nil? || ref == ""
38
- ref.gsub(/[\(\)]/,"").split(/,\s?/).each { |r| self << r }
38
+ ref.gsub(/[\(\)]/,"").split(/,\s?/).each { |r| self << escape(r) }
39
39
  end
40
40
 
41
41
  def <<(full_ref)
@@ -65,6 +65,10 @@ module Capillary
65
65
  end
66
66
 
67
67
  private
68
+ def escape(str)
69
+ HTMLEntities.new.encode(str)
70
+ end
71
+
68
72
  def append_array_in_hash(hash, key, names)
69
73
  hash[key] ||= []
70
74
  hash[key] << names.join("/")
@@ -18,5 +18,5 @@
18
18
 
19
19
 
20
20
  module Capillary
21
- VERSION = "1.0.3"
21
+ VERSION = "1.0.4"
22
22
  end
@@ -20,55 +20,55 @@ require "test_helper"
20
20
  require "capillary/commit"
21
21
 
22
22
  class CommitTest < MiniTest::Spec
23
- context "Parsing a commit line" do
24
- setup do
23
+ describe "Parsing a commit line" do
24
+ before do
25
25
  git_line = fixture("first_commit.txt")
26
26
  @commit = Capillary::Commit.parse(git_line)
27
27
  end
28
28
 
29
- should "extract the commit sha" do
29
+ it "extracts the commit sha" do
30
30
  assert_equal "a7cf78bfff06d52b5b0aa021508b44c00cad067a", @commit.id
31
31
  end
32
32
 
33
- should "extract parent(s)" do
33
+ it "extracts parent(s)" do
34
34
  assert_equal(["db75ad82d678d51b29709d26af64d4a85b6f8071"], @commit.parent_ids)
35
35
  end
36
36
 
37
- should "extract the commit time" do
37
+ it "extracts the commit time" do
38
38
  assert_equal(Time.parse("2011-07-13 07:55:47 +0200"), @commit.committed_at)
39
39
  end
40
40
 
41
- should "extract the committer email" do
41
+ it "extracts the committer email" do
42
42
  assert_equal "chris@example.com", @commit.committer_email
43
43
  end
44
44
 
45
- should "extract the commit message" do
46
- assert_equal "And this is commit 10 Merge branch 'topic'", @commit.message
45
+ it "extracts the commit message" do
46
+ assert_equal "And this is commit 10 Merge branch &apos;topic&apos;", @commit.message
47
47
  end
48
48
 
49
- should "include specified heads" do
49
+ it "includes specified heads" do
50
50
  assert_equal(["master","refactor"], @commit.refs.heads)
51
51
  end
52
52
 
53
- should "include specified tags" do
53
+ it "includes specified tags" do
54
54
  assert_equal(["v2.0.0"], @commit.refs.tags)
55
55
  end
56
56
 
57
- should "convert commit to JSON" do
57
+ it "converts commit to JSON" do
58
58
  assert_equal JSON.parse(@commit.to_json), {
59
59
  "id" => "a7cf78bfff06d52b5b0aa021508b44c00cad067a",
60
60
  "parentIds" => ["db75ad82d678d51b29709d26af64d4a85b6f8071"],
61
61
  "committedAt" => Time.parse("Wed Jul 13 07:55:47 +0200 2011").to_s,
62
62
  "committerEmail" => "chris@example.com",
63
63
  "refs" => { "heads" => ["master", "refactor"], "tags" => ["v2.0.0"], "remotes" => {} },
64
- "message" => "And this is commit 10 Merge branch 'topic'",
64
+ "message" => "And this is commit 10 Merge branch &apos;topic&apos;",
65
65
  "seqId" => nil
66
66
  }
67
67
  end
68
68
 
69
- should "remove HTML tags from output" do
69
+ it "removes HTML tags from output" do
70
70
  @commit.message = '<script>hello</script>'
71
- assert_equal "scripthello/script", @commit.message
71
+ assert_equal "&lt;script&gt;hello&lt;/script&gt;", @commit.message
72
72
  end
73
73
  end
74
74
  end
@@ -46,8 +46,8 @@ class LogParserTest < MiniTest::Spec
46
46
 
47
47
  # * a7cf78bfff06d52b5b0aa021508b44c00cad067a
48
48
  # * db75ad82d678d51b29709d26af64d4a85b6f8071
49
- context "A linear graph" do
50
- setup do
49
+ describe "A linear graph" do
50
+ before do
51
51
  first_line = Capillary::Commit.parse(fixture("first_commit.txt"))
52
52
  second_line = Capillary::Commit.parse(fixture("parent_commit.txt"))
53
53
  @log_parser = Capillary::LogParser.new
@@ -55,22 +55,22 @@ class LogParserTest < MiniTest::Spec
55
55
  @log_parser << second_line
56
56
  end
57
57
 
58
- should "have one branch" do
58
+ it "has one branch" do
59
59
  assert_equal 1, @log_parser.branches.size
60
60
  end
61
61
 
62
- should "index the commits correctly" do
62
+ it "indexes the commits correctly" do
63
63
  branch = @log_parser.branches.first
64
64
  ids = branch.map { |commit| commit.seq_id }
65
65
  assert_equal([0, 1], ids)
66
66
  end
67
67
 
68
- should "collect the shas in correct order" do
68
+ it "collects the shas in correct order" do
69
69
  shas = @log_parser.branches.first.map { |commit| commit.id }
70
70
  assert_equal(["a7cf78bfff06d52b5b0aa021508b44c00cad067a","db75ad82d678d51b29709d26af64d4a85b6f8071"], shas)
71
71
  end
72
72
 
73
- should "render JSON" do
73
+ it "renders JSON" do
74
74
  result = JSON.parse(@log_parser.to_json)
75
75
  assert_equal(1, result.size)
76
76
  commits = result.first
@@ -83,8 +83,8 @@ class LogParserTest < MiniTest::Spec
83
83
  # | *
84
84
  # * |
85
85
  # | |
86
- context "Two merged branches" do
87
- setup do
86
+ describe "Two merged branches" do
87
+ before do
88
88
  fixtures = fixture("two_merged_branches.txt").split("\n")
89
89
  @lines = [Capillary::Commit.parse(fixtures[0]),
90
90
  Capillary::Commit.parse(fixtures[1]),
@@ -96,21 +96,21 @@ class LogParserTest < MiniTest::Spec
96
96
  @log_parser << @lines[2]
97
97
  end
98
98
 
99
- should "have two branches" do
99
+ it "has two branches" do
100
100
  assert_equal 2, @log_parser.branches.size
101
101
  end
102
102
 
103
- should "have two commits in the first branch" do
103
+ it "has two commits in the first branch" do
104
104
  first_branch = @log_parser.branches.first
105
105
  assert_equal 2, first_branch.size
106
106
  end
107
107
 
108
- should "have two commits in the second branch" do
108
+ it "has two commits in the second branch" do
109
109
  last_branch = @log_parser.branches.last
110
110
  assert_equal 2, last_branch.size
111
111
  end
112
112
 
113
- should "put the right commits in the right branch" do
113
+ it "puts the right commits in the right branch" do
114
114
  branches = @log_parser.branches
115
115
 
116
116
  assert_equal @lines[0].id, branches[0][0].id
@@ -120,7 +120,7 @@ class LogParserTest < MiniTest::Spec
120
120
  assert_equal @lines[1].id, branches[1][1].id
121
121
  end
122
122
 
123
- should "render JSON" do
123
+ it "renders JSON" do
124
124
  result = JSON.parse(@log_parser.to_json)
125
125
  assert_equal(2, result.size)
126
126
  assert_equal(2, result.first.size)
@@ -134,8 +134,8 @@ class LogParserTest < MiniTest::Spec
134
134
  # | 0
135
135
  # |/
136
136
  # 0
137
- context "sequence ids" do
138
- should "use same sequence id for merge commit in all affected branches" do
137
+ describe "sequence ids" do
138
+ it "uses same sequence id for merge commit in all affected branches" do
139
139
  fixtures = fixture("simple_graph_no_ff.txt").split("\n")
140
140
  log = Capillary::LogParser.new
141
141
  fixtures.reject { |f| f.strip == "" }.each { |f| log << f }
@@ -173,36 +173,36 @@ class LogParserTest < MiniTest::Spec
173
173
  # | | |/
174
174
  # | | 0
175
175
  # | | |
176
- context "Complex graph merged with --no-ff" do
177
- setup do
176
+ describe "Complex graph merged with --no-ff" do
177
+ before do
178
178
  load_fixture("complex_graph_no_ff.txt")
179
179
  end
180
180
 
181
- should "have four branches" do
181
+ it "has four branches" do
182
182
  assert_equal 4, @log_parser.branches.size
183
183
  end
184
184
 
185
- should "have one commit in the first branch" do
185
+ it "has one commit in the first branch" do
186
186
  branch = @log_parser.branches.first
187
187
  assert_equal 1, branch.size
188
188
  end
189
189
 
190
- should "have five commits in the second branch" do
190
+ it "has five commits in the second branch" do
191
191
  branch = @log_parser.branches[1]
192
192
  assert_equal 5, branch.size
193
193
  end
194
194
 
195
- should "have four commits in the third branch" do
195
+ it "has four commits in the third branch" do
196
196
  branch = @log_parser.branches[2]
197
197
  assert_equal 4, branch.size
198
198
  end
199
199
 
200
- should "have four commits in the fourth branch" do
200
+ it "has four commits in the fourth branch" do
201
201
  branch = @log_parser.branches[3]
202
202
  assert_equal 4, branch.size
203
203
  end
204
204
 
205
- should "put the right commits in the right branch" do
205
+ it "puts the right commits in the right branch" do
206
206
  branches = @log_parser.branches
207
207
 
208
208
  assert_equal @lines[0].id, branches[0][0].id
@@ -211,7 +211,7 @@ class LogParserTest < MiniTest::Spec
211
211
  assert_equal @lines[3].id, branches[3][0].id
212
212
  end
213
213
 
214
- should "render JSON" do
214
+ it "renders JSON" do
215
215
  result = JSON.parse(@log_parser.to_json)
216
216
 
217
217
  assert_equal(4, result.size)
@@ -244,32 +244,32 @@ class LogParserTest < MiniTest::Spec
244
244
  # |/
245
245
  # 0
246
246
  # |
247
- context "Complex graph merged with --no-ff" do
248
- setup do
247
+ describe "Complex graph merged with --no-ff" do
248
+ before do
249
249
  load_fixture("complex_graph.txt")
250
250
  end
251
251
 
252
- should "have three branches" do
252
+ it "has three branches" do
253
253
  assert_equal 3, @log_parser.branches.size
254
254
  end
255
255
 
256
- should "have five commits in the first branch" do
256
+ it "has five commits in the first branch" do
257
257
  assert_equal 5, @log_parser.branches.first.size
258
258
  end
259
259
 
260
- should "have seven commits in the second branch" do
260
+ it "has seven commits in the second branch" do
261
261
  assert_equal 7, @log_parser.branches[1].size
262
262
  end
263
263
 
264
- should "have three commits in the third branch" do
264
+ it "has three commits in the third branch" do
265
265
  assert_equal 4, @log_parser.branches[2].size
266
266
  end
267
267
 
268
- should "not create more seq_id's than there are commits" do
268
+ it "does not create more seq_id's than there are commits" do
269
269
  assert_equal [0, 1, 2, 3, 10], @log_parser.branches.first.collect { |c| c.seq_id }
270
270
  end
271
271
 
272
- should "not represent same commit under different seq_id's" do
272
+ it "does not represent same commit under different seq_id's" do
273
273
  assert_equal [2, 4, 5, 6, 7, 9, 10], @log_parser.branches[1].collect { |c| c.seq_id }
274
274
  assert_equal [5, 8, 9, 10], @log_parser.branches[2].collect { |c| c.seq_id }
275
275
  end
@@ -295,12 +295,12 @@ class LogParserTest < MiniTest::Spec
295
295
  # | |
296
296
  # | 0
297
297
  # | |
298
- context "Parsing log --graph output" do
299
- setup do
298
+ describe "Parsing log --graph output" do
299
+ before do
300
300
  load_fixture("log_graph.txt")
301
301
  end
302
302
 
303
- should "have two branches" do
303
+ it "has two branches" do
304
304
  assert_equal 2, @log_parser.branches.length
305
305
  end
306
306
  end
@@ -345,30 +345,30 @@ class LogParserTest < MiniTest::Spec
345
345
  # |
346
346
  # 0
347
347
  # |
348
- context "Two branches forked from same commit" do
349
- setup do
348
+ describe "Two branches forked from same commit" do
349
+ before do
350
350
  load_fixture("double_fork.txt")
351
351
  end
352
352
 
353
- should "have three branches" do
353
+ it "has three branches" do
354
354
  assert_equal 3, branches.length
355
355
  end
356
356
 
357
- should "have six commits in the first branch" do
357
+ it "has six commits in the first branch" do
358
358
  commits = @log_parser.branches[0].collect { |c| c.id[0...7] }
359
359
 
360
360
  assert_equal 6, commits.length
361
361
  assert_equal %w[0f54800 5bdf304 2477a17 ea4d6ce fdc39f6 9002b5b], commits
362
362
  end
363
363
 
364
- should "have eleven commits in the second branch" do
364
+ it "has eleven commits in the second branch" do
365
365
  commits = @log_parser.branches[1].collect { |c| c.id[0...7] }
366
366
 
367
367
  assert_equal 11, commits.length
368
368
  assert_equal %w[2477a17 13c727b bd73540 6fb3997 9266f54 a5f9deb 1551dfe 16d2ac1 1e69972 fdc39f6 9002b5b], commits
369
369
  end
370
370
 
371
- should "have nine commits in the third branch" do
371
+ it "has nine commits in the third branch" do
372
372
  commits = @log_parser.branches[2].collect { |c| c.id[0...7] }
373
373
 
374
374
  assert_equal 9, commits.length
@@ -380,23 +380,23 @@ class LogParserTest < MiniTest::Spec
380
380
  # |\
381
381
  # | 0
382
382
  # | |
383
- context "Two dangling branches" do
384
- setup do
383
+ describe "Two dangling branches" do
384
+ before do
385
385
  parse_log <<-GIT
386
386
  ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
387
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§
388
388
  GIT
389
389
  end
390
390
 
391
- should "have two branches" do
391
+ it "has two branches" do
392
392
  assert_equal 2, branches.length
393
393
  end
394
394
 
395
- should "have one commit in first branch" do
395
+ it "has one commit in first branch" do
396
396
  assert_equal %w[ca2d07e], commits_for_branch(0)
397
397
  end
398
398
 
399
- should "have two commits in second branch" do
399
+ it "has two commits in second branch" do
400
400
  assert_equal %w[ca2d07e c4e7446], commits_for_branch(1)
401
401
  end
402
402
  end
@@ -407,8 +407,8 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
407
407
  # |\
408
408
  # | 0
409
409
  # | |
410
- context "Two dangling branches with leading commit" do
411
- setup do
410
+ describe "Two dangling branches with leading commit" do
411
+ before do
412
412
  parse_log <<-GIT
413
413
  1f2b8a4e3f61ffedf9908e28b280de8c6bf38a16§ca2d07e0172565c9e0f18d41e49b70d7d75fced6§Tue May 10 13:04:10 2011 +0200§christian@gitorious.org§§Some commit§
414
414
  ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
@@ -416,15 +416,15 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
416
416
  GIT
417
417
  end
418
418
 
419
- should "have two branches" do
419
+ it "has two branches" do
420
420
  assert_equal 2, branches.length
421
421
  end
422
422
 
423
- should "have two commits in first branch" do
423
+ it "has two commits in first branch" do
424
424
  assert_equal %w[1f2b8a4 ca2d07e], commits_for_branch(0)
425
425
  end
426
426
 
427
- should "have two commits in second branch" do
427
+ it "has two commits in second branch" do
428
428
  assert_equal %w[ca2d07e c4e7446], commits_for_branch(1)
429
429
  end
430
430
  end
@@ -435,8 +435,8 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
435
435
  # | |\
436
436
  # | | 0
437
437
  # | | |
438
- context "Three dangling branches" do
439
- setup do
438
+ describe "Three dangling branches" do
439
+ before do
440
440
  parse_log <<-GIT
441
441
  1f2b8a4e3f61ffedf9908e28b280de8c6bf38a16§ca2d07e0172565c9e0f18d41e49b70d7d75fced6 275932ab0995a11fcebeb0af7f19a7b8df5dea3f§Tue May 10 13:04:10 2011 +0200§christian@gitorious.org§§Some commit§
442
442
  ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
@@ -444,19 +444,19 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
444
444
  GIT
445
445
  end
446
446
 
447
- should "have three branches" do
447
+ it "has three branches" do
448
448
  assert_equal 3, branches.length
449
449
  end
450
450
 
451
- should "have two commits in first branch" do
451
+ it "has two commits in first branch" do
452
452
  assert_equal %w[1f2b8a4 ca2d07e], commits_for_branch(0)
453
453
  end
454
454
 
455
- should "have one commit in second branch" do
455
+ it "has one commit in second branch" do
456
456
  assert_equal %w[1f2b8a4], commits_for_branch(1)
457
457
  end
458
458
 
459
- should "have two commits in third branch" do
459
+ it "has two commits in third branch" do
460
460
  assert_equal %w[ca2d07e c4e7446], commits_for_branch(2)
461
461
  end
462
462
  end
@@ -472,8 +472,8 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
472
472
  # |\ |
473
473
  # | 0 |
474
474
  # | | |
475
- context "Three dangling branches with closed branch" do
476
- setup do
475
+ describe "Three dangling branches with closed branch" do
476
+ before do
477
477
  parse_log <<-GIT
478
478
  0000000000000000000000000000000000000000§1111111111111111111111111111111111111111 3333333333333333333333333333333333333333§Tue May 10 13:00:00 2011 +0200§christian@gitorious.org§§Message§
479
479
  1111111111111111111111111111111111111111§4444444444444444444444444444444444444444 2222222222222222222222222222222222222222§Tue May 10 12:00:00 2011 +0200§christian@gitorious.org§§Message§
@@ -484,23 +484,23 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
484
484
  GIT
485
485
  end
486
486
 
487
- should "have four branches" do
487
+ it "has four branches" do
488
488
  assert_equal 4, branches.length
489
489
  end
490
490
 
491
- should "have three commits in first branch" do
491
+ it "has three commits in first branch" do
492
492
  assert_equal %w[0000000 1111111 4444444], commits_for_branch(0)
493
493
  end
494
494
 
495
- should "two commits in second branch" do
495
+ it "has two commits in second branch" do
496
496
  assert_equal %w[0000000 3333333], commits_for_branch(1)
497
497
  end
498
498
 
499
- should "have three commits in third branch" do
499
+ it "has three commits in third branch" do
500
500
  assert_equal %w[1111111 2222222 4444444], commits_for_branch(2)
501
501
  end
502
502
 
503
- should "have two commits in fourth branch" do
503
+ it "has two commits in fourth branch" do
504
504
  assert_equal %w[4444444 5555555], commits_for_branch(3)
505
505
  end
506
506
  end
@@ -509,27 +509,27 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
509
509
  # |\
510
510
  # | 0
511
511
  # | |\
512
- context "two commits with two parents" do
513
- setup do
512
+ describe "two commits with two parents" do
513
+ before do
514
514
  parse_log <<-GIT
515
515
  ca2d07e0172565c9e0f18d41e49b70d7d75fced6§3370cb3615b3368be97c0f39b86f5dc2f9fa3650 c4e7446e2a98f1bf28da51fc57bb42b532222942§Tue May 10 12:47:08 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/2230'§
516
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
517
  GIT
518
518
  end
519
519
 
520
- should "have three branches" do
520
+ it "has three branches" do
521
521
  assert_equal 3, branches.length
522
522
  end
523
523
 
524
- should "have one commit in the first branch" do
524
+ it "has one commit in the first branch" do
525
525
  assert_equal %w[ca2d07e], commits_for_branch(0)
526
526
  end
527
527
 
528
- should "have two commits in the second branch" do
528
+ it "has two commits in the second branch" do
529
529
  assert_equal %w[ca2d07e c4e7446], commits_for_branch(1)
530
530
  end
531
531
 
532
- should "have three commits in the third branch" do
532
+ it "has three commits in the third branch" do
533
533
  assert_equal %w[c4e7446], commits_for_branch(2)
534
534
  end
535
535
  end
@@ -544,8 +544,8 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
544
544
  # | \ | # |\ |
545
545
  # | c4e7446-|- # | 0-|
546
546
  # | | | \ # | | |\
547
- context "Three branches from four dangling branches" do
548
- setup do
547
+ describe "Three branches from four dangling branches" do
548
+ before do
549
549
  parse_log <<-GIT
550
550
  1f2b8a4e3f61ffedf9908e28b280de8c6bf38a16§ca2d07e0172565c9e0f18d41e49b70d7d75fced6 a2f271b1aa55e52ba848779c62a6fa02cbc5ea0c§Tue May 10 13:04:10 2011 +0200§christian@gitorious.org§§Merge branch 'merge-requests/147'§
551
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§
@@ -555,27 +555,27 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
555
555
  GIT
556
556
  end
557
557
 
558
- should "have five branches" do
558
+ it "has five branches" do
559
559
  assert_equal 5, branches.length
560
560
  end
561
561
 
562
- should "have two commits in first branch" do
562
+ it "has two commits in first branch" do
563
563
  assert_equal %w[1f2b8a4 ca2d07e], commits_for_branch(0)
564
564
  end
565
565
 
566
- should "have three commits in second branch" do
566
+ it "has three commits in second branch" do
567
567
  assert_equal %w[1f2b8a4 a2f271b ca2d07e], commits_for_branch(1)
568
568
  end
569
569
 
570
- should "have two commits in third branch" do
570
+ it "has two commits in third branch" do
571
571
  assert_equal %w[a2f271b 3ec0ec6], commits_for_branch(2)
572
572
  end
573
573
 
574
- should "have two commits in fourth branch" do
574
+ it "has two commits in fourth branch" do
575
575
  assert_equal %w[ca2d07e c4e7446], commits_for_branch(3)
576
576
  end
577
577
 
578
- should "have one commit in fifth branch" do
578
+ it "has one commit in fifth branch" do
579
579
  assert_equal %w[c4e7446], commits_for_branch(4)
580
580
  end
581
581
  end
@@ -600,53 +600,53 @@ c4e7446e2a98f1bf28da51fc57bb42b532222942§c3e1d675667939e64ced1bb5b541c9042a1d60
600
600
  # | \ | |
601
601
  # | c4e7446-|-------|------
602
602
  # | | | | \
603
- context "Four dangling branches" do
604
- setup do
603
+ describe "Four dangling branches" do
604
+ before do
605
605
  load_fixture("4x_dangling_branches.txt")
606
606
  end
607
607
 
608
- should "have seven branches" do
608
+ it "has seven branches" do
609
609
  assert_equal 7, branches.length
610
610
  end
611
611
 
612
- should "have 3 commits in the first branch" do
612
+ it "has 3 commits in the first branch" do
613
613
  assert_equal %w[44c5c1d 1f2b8a4 ca2d07e], commits_for_branch(0)
614
614
  end
615
615
 
616
- should "have 3 commits in the second branch" do
616
+ it "has 3 commits in the second branch" do
617
617
  assert_equal %w[44c5c1d e81d019 1f2b8a4 ca2d07e], commits_for_branch(1)
618
618
  end
619
619
 
620
- should "have 2 commits in the third branch" do
620
+ it "has 2 commits in the third branch" do
621
621
  assert_equal %w[e81d019 bbbd502], commits_for_branch(2)
622
622
  end
623
623
 
624
- should "have 5 commits in the fourth branch" do
624
+ it "has 5 commits in the fourth branch" do
625
625
  assert_equal %w[1f2b8a4 275932a 7487183 a2f271b ca2d07e], commits_for_branch(3)
626
626
  end
627
627
 
628
- should "have 2 commits in the fifth branch" do
628
+ it "has 2 commits in the fifth branch" do
629
629
  assert_equal %w[a2f271b 3ec0ec6], commits_for_branch(4)
630
630
  end
631
631
 
632
- should "have 2 commits in the sixth branch" do
632
+ it "has 2 commits in the sixth branch" do
633
633
  assert_equal %w[ca2d07e c4e7446], commits_for_branch(5)
634
634
  end
635
635
  end
636
636
 
637
- context "Streaming parser" do
638
- setup do
637
+ describe "Streaming parser" do
638
+ before do
639
639
  @lines = fixture("complex_graph_no_ff.txt").split("\n")
640
640
  @log = Capillary::LogParser.new
641
641
  end
642
642
 
643
- should "add parsed line" do
643
+ it "adds parsed line" do
644
644
  @log << Capillary::Commit.parse(@lines[0])
645
645
 
646
646
  assert_equal 2, @log.branches.length
647
647
  end
648
648
 
649
- should "add raw line" do
649
+ it "adds raw line" do
650
650
  @log << @lines[0]
651
651
 
652
652
  assert_equal 2, @log.branches.length
@@ -20,8 +20,8 @@ require "test_helper"
20
20
  require "capillary/ref_collection"
21
21
 
22
22
  class RefCollectionTest < MiniTest::Spec
23
- context "Parsing refs" do
24
- should "ignore HEAD" do
23
+ describe "Parsing refs" do
24
+ it "ignores HEAD" do
25
25
  refs = Capillary::RefCollection.parse("HEAD")
26
26
 
27
27
  refute refs.to_hash.key?(nil)
@@ -29,28 +29,39 @@ class RefCollectionTest < MiniTest::Spec
29
29
  assert_equal [], refs.tags
30
30
  end
31
31
 
32
- should "find heads" do
32
+ it "finds heads" do
33
33
  refs = Capillary::RefCollection.parse("(HEAD, refs/heads/master)")
34
34
 
35
35
  assert_equal ["master"], refs.heads
36
36
  end
37
37
 
38
- should "find tags" do
38
+ it "finds tags" do
39
39
  refs = Capillary::RefCollection.parse("(HEAD, refs/heads/master, refs/tags/v2.0.0)")
40
40
 
41
41
  assert_equal ["v2.0.0"], refs.tags
42
42
  end
43
43
 
44
- should "find remotes" do
44
+ it "finds remotes" do
45
45
  refs = Capillary::RefCollection.parse("(HEAD, refs/heads/master, refs/tags/v2.0.0, refs/remotes/origin/branch)")
46
46
 
47
47
  assert_equal({ "origin" => ["branch"] }, refs.remotes)
48
48
  end
49
49
 
50
- should "find merge requests" do
50
+ it "finds merge requests" do
51
51
  refs = Capillary::RefCollection.parse("(HEAD, refs/merge-requests/1304)")
52
52
 
53
53
  assert_equal ["1304"], refs.merge_requests
54
54
  end
55
+
56
+ it "escapes the refs" do
57
+ refs = Capillary::RefCollection.parse("(HEAD, refs/heads/<master>, refs/tags/<v2.0.0>, refs/remotes/<origin>/<branch>)")
58
+
59
+ safe_refs = {
60
+ "remotes" => { "&lt;origin&gt;" => ["&lt;branch&gt;"] },
61
+ "tags" => ["&lt;v2.0.0&gt;"],
62
+ "heads" => ["&lt;master&gt;"]
63
+ }
64
+ assert_equal safe_refs, refs.to_hash
65
+ end
55
66
  end
56
67
  end
@@ -1,7 +1,13 @@
1
+ if RUBY_VERSION > "1.9"
2
+ require "simplecov"
3
+ require "simplecov-rcov"
4
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
5
+ SimpleCov.start
6
+ end
7
+
1
8
  require "rubygems"
2
9
  require "bundler/setup"
3
10
  require "minitest/autorun"
4
- require "mini_shoulda"
5
11
 
6
12
  module Fixtures
7
13
  def fixture(filename)
metadata CHANGED
@@ -1,94 +1,92 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capillary
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.4
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 3
10
- version: 1.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Marius Mathiesen
14
9
  - Christian Johansen
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2013-06-28 00:00:00 +02:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2013-10-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: json
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.5'
23
+ type: :runtime
24
24
  prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
26
26
  none: false
27
- requirements:
27
+ requirements:
28
28
  - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 5
31
- segments:
32
- - 1
33
- - 5
34
- version: "1.5"
29
+ - !ruby/object:Gem::Version
30
+ version: '1.5'
31
+ - !ruby/object:Gem::Dependency
32
+ name: htmlentities
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
35
39
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: minitest
39
40
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
+ version_requirements: !ruby/object:Gem::Requirement
41
42
  none: false
42
- requirements:
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
43
52
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 2
48
- - 0
49
- version: "2.0"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
50
55
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: mini_shoulda
54
56
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
57
+ version_requirements: !ruby/object:Gem::Requirement
56
58
  none: false
57
- requirements:
59
+ requirements:
58
60
  - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 13
61
- segments:
62
- - 0
63
- - 3
64
- version: "0.3"
65
- type: :development
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
61
+ - !ruby/object:Gem::Version
62
+ version: '2.0'
63
+ - !ruby/object:Gem::Dependency
68
64
  name: rake
69
- prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
71
66
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
79
71
  type: :development
80
- version_requirements: *id004
81
- description: Capillary works in conjunction with capillary.js, which outputs a beautiful graphical representation of your repository history
82
- email:
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ description: Capillary works in conjunction with capillary.js, which outputs a beautiful
80
+ graphical representation of your repository history
81
+ email:
83
82
  - marius@gitorious.org
84
83
  - christian@gitorious.org
85
- executables:
84
+ executables:
86
85
  - capillary
87
86
  extensions: []
88
-
89
87
  extra_rdoc_files: []
90
-
91
- files:
88
+ files:
89
+ - .gitignore
92
90
  - Gemfile
93
91
  - Gemfile.lock
94
92
  - LICENSE
@@ -115,39 +113,28 @@ files:
115
113
  - test/fixtures/third_commit.txt
116
114
  - test/fixtures/two_merged_branches.txt
117
115
  - test/test_helper.rb
118
- has_rdoc: true
119
116
  homepage: http://gitorious.org/capillary
120
117
  licenses: []
121
-
122
118
  post_install_message:
123
119
  rdoc_options: []
124
-
125
- require_paths:
120
+ require_paths:
126
121
  - lib
127
- required_ruby_version: !ruby/object:Gem::Requirement
122
+ required_ruby_version: !ruby/object:Gem::Requirement
128
123
  none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- hash: 3
133
- segments:
134
- - 0
135
- version: "0"
136
- required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
129
  none: false
138
- requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- hash: 3
142
- segments:
143
- - 0
144
- version: "0"
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
145
134
  requirements: []
146
-
147
135
  rubyforge_project: capillary
148
- rubygems_version: 1.4.2
136
+ rubygems_version: 1.8.25
149
137
  signing_key:
150
138
  specification_version: 3
151
139
  summary: Capillary generates a JSON payload from Git log output
152
140
  test_files: []
153
-