capillary 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -2
- data/README +1 -1
- data/lib/capillary/commit.rb +8 -2
- data/lib/capillary/log_parser.rb +33 -9
- data/lib/capillary/version.rb +1 -1
- data/test/capillary/commit_test.rb +6 -5
- data/test/capillary/log_parser_test.rb +61 -0
- data/test/fixtures/complex_graph.txt +11 -0
- metadata +6 -5
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ PATH
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
json (1.5.
|
10
|
+
json (1.5.3)
|
11
11
|
mini_shoulda (0.3.0)
|
12
12
|
minitest (~> 2.1.0)
|
13
13
|
minitest (2.1.0)
|
@@ -17,6 +17,5 @@ PLATFORMS
|
|
17
17
|
|
18
18
|
DEPENDENCIES
|
19
19
|
capillary!
|
20
|
-
json (~> 1.5.1)
|
21
20
|
mini_shoulda (~> 0.3.0)
|
22
21
|
minitest (~> 2.0)
|
data/README
CHANGED
@@ -36,7 +36,7 @@ Capillary parses output from Git, in the format as specified in
|
|
36
36
|
test/fixtures/single_commit.txt. This output was generated from Git using the
|
37
37
|
following command:
|
38
38
|
|
39
|
-
git log --
|
39
|
+
git log --pretty=format:"%H§%P§%ad§%ae§%d§%s§"
|
40
40
|
|
41
41
|
The name
|
42
42
|
--------
|
data/lib/capillary/commit.rb
CHANGED
@@ -19,7 +19,7 @@ require "time"
|
|
19
19
|
|
20
20
|
module Capillary
|
21
21
|
class Commit
|
22
|
-
attr_accessor :id, :parent_ids, :committed_at, :message, :committer_email
|
22
|
+
attr_accessor :id, :parent_ids, :committed_at, :message, :committer_email, :seq_id
|
23
23
|
attr_reader :ref_names
|
24
24
|
LOG_SEPARATOR = "§"
|
25
25
|
|
@@ -54,7 +54,13 @@ module Capillary
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def to_json
|
57
|
-
JSON.unparse(
|
57
|
+
JSON.unparse({ "id" => id,
|
58
|
+
"parentIds" => parent_ids,
|
59
|
+
"committedAt" => committed_at,
|
60
|
+
"committerEmail" => committer_email,
|
61
|
+
"refNames" => ref_names,
|
62
|
+
"message" => message,
|
63
|
+
"seqId" => seq_id})
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
data/lib/capillary/log_parser.rb
CHANGED
@@ -26,6 +26,7 @@ module Capillary
|
|
26
26
|
@commit_count = 0
|
27
27
|
@branches = []
|
28
28
|
@seq_ids = {}
|
29
|
+
@commit_positions = {}
|
29
30
|
end
|
30
31
|
|
31
32
|
def <<(commit)
|
@@ -41,34 +42,57 @@ module Capillary
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def to_json
|
44
|
-
|
45
|
+
branches_json = branches.collect do |b|
|
46
|
+
"[" + b.collect { |c| "#{c.to_json}" }.join(",") + "]"
|
47
|
+
end
|
48
|
+
|
49
|
+
"[#{branches_json.join(', ')}]"
|
45
50
|
end
|
46
51
|
|
47
52
|
private
|
48
53
|
def place_commit(commit)
|
49
|
-
|
50
|
-
|
54
|
+
col = 0
|
55
|
+
|
56
|
+
placed = branches.inject(false) do |was_placed, branch|
|
57
|
+
if !branch.last.closed? && branch.last.parent_id == commit.id
|
58
|
+
pos = @commit_positions[branch.last.parent_id]
|
59
|
+
|
60
|
+
if pos
|
61
|
+
diff = (pos.first - col).abs
|
62
|
+
next true if diff > 1
|
63
|
+
else
|
64
|
+
@commit_positions[commit.id] = [col, branch.length]
|
65
|
+
end
|
66
|
+
|
51
67
|
branch << commit
|
52
|
-
|
68
|
+
was_placed = true
|
53
69
|
end
|
54
70
|
|
55
|
-
|
71
|
+
col += 1
|
72
|
+
was_placed
|
56
73
|
end
|
57
74
|
|
58
|
-
|
75
|
+
unless placed
|
76
|
+
@commit_positions[commit.id] = [col, 0]
|
77
|
+
branches << [commit]
|
78
|
+
end
|
59
79
|
end
|
60
80
|
end
|
61
81
|
|
62
82
|
class CommitNode
|
63
|
-
attr_reader :
|
83
|
+
attr_reader :commit, :parent_id
|
64
84
|
|
65
85
|
def initialize(seq_id, commit, parent_id)
|
66
|
-
@seq_id = seq_id
|
67
86
|
@commit = commit
|
87
|
+
@commit.seq_id = seq_id
|
68
88
|
@parent_id = parent_id
|
89
|
+
@closed = false
|
69
90
|
end
|
70
91
|
|
92
|
+
def seq_id; commit.seq_id; end
|
71
93
|
def id; commit.id; end
|
72
|
-
def
|
94
|
+
def to_json; commit.to_json; end
|
95
|
+
def closed?; @closed; end
|
96
|
+
def close; @closed = true; end
|
73
97
|
end
|
74
98
|
end
|
data/lib/capillary/version.rb
CHANGED
@@ -58,11 +58,12 @@ class CommitTest < MiniTest::Spec
|
|
58
58
|
should "convert commit to JSON" do
|
59
59
|
assert_equal JSON.parse(@commit.to_json), {
|
60
60
|
"id" => "a7cf78bfff06d52b5b0aa021508b44c00cad067a",
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"
|
64
|
-
"
|
65
|
-
"message" => "And this is commit 10 Merge branch 'topic'"
|
61
|
+
"parentIds" => ["db75ad82d678d51b29709d26af64d4a85b6f8071"],
|
62
|
+
"committedAt" => "Wed Jul 13 07:55:47 +0200 2011",
|
63
|
+
"committerEmail" => "chris@example.com",
|
64
|
+
"refNames" => ["master", "refactor"],
|
65
|
+
"message" => "And this is commit 10 Merge branch 'topic'",
|
66
|
+
"seqId" => nil
|
66
67
|
}
|
67
68
|
end
|
68
69
|
end
|
@@ -204,6 +204,67 @@ class LogParserTest < MiniTest::Spec
|
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
+
#
|
208
|
+
# 0
|
209
|
+
# |
|
210
|
+
# 0
|
211
|
+
# |
|
212
|
+
# 0
|
213
|
+
# |\
|
214
|
+
# 0 |
|
215
|
+
# | |
|
216
|
+
# | 0
|
217
|
+
# | |
|
218
|
+
# | 0
|
219
|
+
# | |\
|
220
|
+
# | 0 |
|
221
|
+
# | | |
|
222
|
+
# | 0 |
|
223
|
+
# | | |
|
224
|
+
# | | 0
|
225
|
+
# | |/
|
226
|
+
# | 0
|
227
|
+
# |/
|
228
|
+
# 0
|
229
|
+
# |
|
230
|
+
context "Complex graph merged with --no-ff" do
|
231
|
+
setup do
|
232
|
+
fixtures = fixture("complex_graph.txt").split("\n")
|
233
|
+
@log_parser = Capillary::LogParser.new
|
234
|
+
@lines = []
|
235
|
+
|
236
|
+
fixtures.reject { |f| f.strip == "" }.each do |fixture|
|
237
|
+
@lines << Capillary::Commit.parse(fixture)
|
238
|
+
@log_parser << @lines.last
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
should "have three branches" do
|
243
|
+
assert_equal 3, @log_parser.branches.size
|
244
|
+
end
|
245
|
+
|
246
|
+
should "have five commits in the first branch" do
|
247
|
+
assert_equal 5, @log_parser.branches.first.size
|
248
|
+
end
|
249
|
+
|
250
|
+
should "have seven commits in the second branch" do
|
251
|
+
assert_equal 7, @log_parser.branches[1].size
|
252
|
+
end
|
253
|
+
|
254
|
+
should "have three commits in the third branch" do
|
255
|
+
assert_equal 3, @log_parser.branches[2].size
|
256
|
+
end
|
257
|
+
|
258
|
+
should "not create more seq_id's than there are commits" do
|
259
|
+
assert_equal [0, 1, 2, 3, 10], @log_parser.branches.first.collect { |c| c.seq_id }
|
260
|
+
end
|
261
|
+
|
262
|
+
should "not represent same commit under different seq_id's" do
|
263
|
+
assert_equal [2, 4, 5, 6, 7, 9, 10], @log_parser.branches[1].collect { |c| c.seq_id }
|
264
|
+
assert_equal [5, 8, 9], @log_parser.branches[2].collect { |c| c.seq_id }
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
207
268
|
context "Streaming parser" do
|
208
269
|
setup do
|
209
270
|
@lines = fixture("complex_graph_no_ff.txt").split("\n")
|
@@ -0,0 +1,11 @@
|
|
1
|
+
ebd6ca933644ace5a405e9300ff3ff86fa9678cf§fe87dba23f935a1a6280fdc00dca01a7502772ce§Fri Jul 15 21:23:55 2011 +0200§christian@gitorious.org§ (HEAD, origin/master, origin/HEAD, master)§Up version and JSON dependency§
|
2
|
+
fe87dba23f935a1a6280fdc00dca01a7502772ce§3244d9ec9024325bee95112da51ebf7636717bd4§Fri Jul 15 21:23:40 2011 +0200§christian@gitorious.org§§Fix JSON output so it uses idiomatic camelCasing for property names§
|
3
|
+
3244d9ec9024325bee95112da51ebf7636717bd4§99626ea0ec232d403395d2e9d7c9ee27017c2f48 50c64c2f9fecdfd32aaf37486106eabe8e3984b7§Fri Jul 15 14:53:16 2011 +0200§marius@gitorious.org§§Merge branch 'master' of gitorious.org:capillary/capillary_rb§
|
4
|
+
99626ea0ec232d403395d2e9d7c9ee27017c2f48§13862a57985d61ae215eab265c4751182303a6e9§Fri Jul 15 14:53:03 2011 +0200§marius@gitorious.org§§Add a failing test for Christian§
|
5
|
+
50c64c2f9fecdfd32aaf37486106eabe8e3984b7§925fee4ceea3b051dbf89e3faa60af5121c4d757§Fri Jul 15 10:50:08 2011 +0200§christian@gitorious.org§§Up gemspec version§
|
6
|
+
925fee4ceea3b051dbf89e3faa60af5121c4d757§6aef451a1e152182c03d141d52e68be8484f51f8 7b4a45d3dd4f35fb8a2c7f941f59e9f9f70f0f95§Fri Jul 15 10:49:53 2011 +0200§christian@gitorious.org§§Merge branch 'master' of gitorious.org:capillary/capillary_
|
7
|
+
6aef451a1e152182c03d141d52e68be8484f51f8§fb6841db8b3b757e961330d9a93895883b26cb31§Fri Jul 15 10:42:46 2011 +0200§christian@gitorious.org§§Don't add merge commits multiple times with different sequence numbers§
|
8
|
+
fb6841db8b3b757e961330d9a93895883b26cb31§faee9a1ce450bb012afe374b8fde93939655ab15§Fri Jul 15 10:41:51 2011 +0200§christian@gitorious.org§§JSON goes out§
|
9
|
+
7b4a45d3dd4f35fb8a2c7f941f59e9f9f70f0f95§faee9a1ce450bb012afe374b8fde93939655ab15§Thu Jul 14 15:08:05 2011 +0200§marius@gitorious.org§§Fix typo in hash representation of Commit, ref_names will always be an array§
|
10
|
+
faee9a1ce450bb012afe374b8fde93939655ab15§13862a57985d61ae215eab265c4751182303a6e9§Thu Jul 14 09:18:59 2011 +0200§marius@gitorious.org§§Adding gemspec along with version§
|
11
|
+
13862a57985d61ae215eab265c4751182303a6e9§d1cec484438bce51a1f5e6f8ed213f014a85a439§Thu Jul 14 07:54:39 2011 +0200§christian@gitorious.org§§Binary for converting log input from stdin to JSON§
|
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
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-
|
19
|
+
date: 2011-08-22 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/capillary/version.rb
|
90
90
|
- test/capillary/commit_test.rb
|
91
91
|
- test/capillary/log_parser_test.rb
|
92
|
+
- test/fixtures/complex_graph.txt
|
92
93
|
- test/fixtures/complex_graph_no_ff.txt
|
93
94
|
- test/fixtures/first_commit.txt
|
94
95
|
- test/fixtures/parent_commit.txt
|