grit 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grit might be problematic. Click here for more details.
- data/History.txt +9 -0
- data/README.md +37 -11
- data/VERSION.yml +3 -3
- data/examples/ex_add_commit.rb +13 -0
- data/examples/ex_index.rb +14 -0
- data/lib/grit.rb +10 -3
- data/lib/grit/actor.rb +5 -5
- data/lib/grit/blob.rb +12 -12
- data/lib/grit/commit.rb +3 -3
- data/lib/grit/commit_stats.rb +26 -26
- data/lib/grit/config.rb +9 -9
- data/lib/grit/diff.rb +16 -16
- data/lib/grit/errors.rb +1 -1
- data/lib/grit/git-ruby.rb +108 -27
- data/lib/grit/git-ruby/commit_db.rb +11 -11
- data/lib/grit/git-ruby/file_index.rb +28 -28
- data/lib/grit/git-ruby/git_object.rb +14 -14
- data/lib/grit/git-ruby/internal/file_window.rb +4 -4
- data/lib/grit/git-ruby/internal/loose.rb +10 -10
- data/lib/grit/git-ruby/internal/pack.rb +29 -29
- data/lib/grit/git-ruby/internal/raw_object.rb +4 -4
- data/lib/grit/git-ruby/object.rb +9 -9
- data/lib/grit/git-ruby/repository.rb +111 -107
- data/lib/grit/git.rb +191 -14
- data/lib/grit/index.rb +21 -21
- data/lib/grit/lazy.rb +1 -1
- data/lib/grit/merge.rb +9 -9
- data/lib/grit/ref.rb +6 -31
- data/lib/grit/repo.rb +110 -65
- data/lib/grit/ruby1.9.rb +1 -1
- data/lib/grit/status.rb +24 -24
- data/lib/grit/submodule.rb +15 -15
- data/lib/grit/tag.rb +7 -57
- data/lib/grit/tree.rb +12 -12
- data/test/bench/benchmarks.rb +126 -0
- data/test/helper.rb +18 -0
- data/test/profile.rb +21 -0
- data/test/suite.rb +6 -0
- data/test/test_actor.rb +35 -0
- data/test/test_blame.rb +32 -0
- data/test/test_blame_tree.rb +33 -0
- data/test/test_blob.rb +83 -0
- data/test/test_commit.rb +207 -0
- data/test/test_commit_stats.rb +33 -0
- data/test/test_commit_write.rb +20 -0
- data/test/test_config.rb +58 -0
- data/test/test_diff.rb +18 -0
- data/test/test_file_index.rb +56 -0
- data/test/test_git.rb +105 -0
- data/test/test_grit.rb +32 -0
- data/test/test_head.rb +47 -0
- data/test/test_index_status.rb +40 -0
- data/test/test_merge.rb +17 -0
- data/test/test_raw.rb +16 -0
- data/test/test_real.rb +19 -0
- data/test/test_reality.rb +17 -0
- data/test/test_remote.rb +14 -0
- data/test/test_repo.rb +349 -0
- data/test/test_rubygit.rb +192 -0
- data/test/test_rubygit_alt.rb +40 -0
- data/test/test_rubygit_index.rb +76 -0
- data/test/test_rubygit_iv2.rb +28 -0
- data/test/test_submodule.rb +69 -0
- data/test/test_tag.rb +67 -0
- data/test/test_tree.rb +101 -0
- metadata +43 -13
data/test/test_tree.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TestTree < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@r = Repo.new(GRIT_REPO)
|
6
|
+
@t = Tree.allocate
|
7
|
+
end
|
8
|
+
|
9
|
+
# contents
|
10
|
+
def test_nosuch_tree
|
11
|
+
t = @r.tree('blahblah')
|
12
|
+
assert t.contents.is_a?(Array)
|
13
|
+
assert t.is_a?(Tree)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_contents_should_cache
|
17
|
+
Git.any_instance.expects(:ls_tree).returns(
|
18
|
+
fixture('ls_tree_a'),
|
19
|
+
fixture('ls_tree_b')
|
20
|
+
).times(2)
|
21
|
+
tree = @r.tree('master')
|
22
|
+
|
23
|
+
child = tree.contents.last
|
24
|
+
|
25
|
+
child.contents
|
26
|
+
child.contents
|
27
|
+
end
|
28
|
+
|
29
|
+
# content_from_string
|
30
|
+
|
31
|
+
def test_content_from_string_tree_should_return_tree
|
32
|
+
text = fixture('ls_tree_a').split("\n").last
|
33
|
+
|
34
|
+
tree = @t.content_from_string(nil, text)
|
35
|
+
|
36
|
+
assert_equal Tree, tree.class
|
37
|
+
assert_equal "650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44", tree.id
|
38
|
+
assert_equal "040000", tree.mode
|
39
|
+
assert_equal "test", tree.name
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_content_from_string_tree_should_return_blob
|
43
|
+
text = fixture('ls_tree_b').split("\n").first
|
44
|
+
|
45
|
+
tree = @t.content_from_string(nil, text)
|
46
|
+
|
47
|
+
assert_equal Blob, tree.class
|
48
|
+
assert_equal "aa94e396335d2957ca92606f909e53e7beaf3fbb", tree.id
|
49
|
+
assert_equal "100644", tree.mode
|
50
|
+
assert_equal "grit.rb", tree.name
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_content_from_string_tree_should_return_submodule
|
54
|
+
text = fixture('ls_tree_submodule').split("\n").first
|
55
|
+
|
56
|
+
sm = @t.content_from_string(nil, text)
|
57
|
+
|
58
|
+
assert_kind_of Submodule, sm
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_content_from_string_invalid_type_should_raise
|
62
|
+
assert_raise(RuntimeError) do
|
63
|
+
@t.content_from_string(nil, "040000 bogus 650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44 test")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# /
|
68
|
+
|
69
|
+
def test_slash
|
70
|
+
Git.any_instance.expects(:ls_tree).returns(
|
71
|
+
fixture('ls_tree_a')
|
72
|
+
)
|
73
|
+
tree = @r.tree('master')
|
74
|
+
|
75
|
+
assert_equal 'aa06ba24b4e3f463b3c4a85469d0fb9e5b421cf8', (tree/'lib').id
|
76
|
+
assert_equal '8b1e02c0fb554eed2ce2ef737a68bb369d7527df', (tree/'README.txt').id
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_slash_with_commits
|
80
|
+
Git.any_instance.expects(:ls_tree).returns(
|
81
|
+
fixture('ls_tree_commit')
|
82
|
+
)
|
83
|
+
tree = @r.tree('master')
|
84
|
+
|
85
|
+
assert_equal 'd35b34c6e931b9da8f6941007a92c9c9a9b0141a', (tree/'bar').id
|
86
|
+
assert_equal '2afb47bcedf21663580d5e6d2f406f08f3f65f19', (tree/'foo').id
|
87
|
+
assert_equal 'f623ee576a09ca491c4a27e48c0dfe04be5f4a2e', (tree/'baz').id
|
88
|
+
end
|
89
|
+
|
90
|
+
# inspect
|
91
|
+
|
92
|
+
def test_inspect
|
93
|
+
@t = Tree.create(@r, :id => 'abc')
|
94
|
+
assert_equal %Q{#<Grit::Tree "abc">}, @t.inspect
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_basename
|
98
|
+
@t = Tree.create(@r, :name => 'foo/bar')
|
99
|
+
assert_equal "bar", @t.basename
|
100
|
+
end
|
101
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-10-27 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -40,14 +40,14 @@ executables: []
|
|
40
40
|
extensions: []
|
41
41
|
|
42
42
|
extra_rdoc_files:
|
43
|
-
- README.md
|
44
43
|
- LICENSE
|
44
|
+
- README.md
|
45
45
|
files:
|
46
46
|
- API.txt
|
47
47
|
- History.txt
|
48
48
|
- README.md
|
49
49
|
- VERSION.yml
|
50
|
-
- lib/grit
|
50
|
+
- lib/grit.rb
|
51
51
|
- lib/grit/actor.rb
|
52
52
|
- lib/grit/blame.rb
|
53
53
|
- lib/grit/blob.rb
|
@@ -56,18 +56,16 @@ files:
|
|
56
56
|
- lib/grit/config.rb
|
57
57
|
- lib/grit/diff.rb
|
58
58
|
- lib/grit/errors.rb
|
59
|
-
- lib/grit/git-ruby
|
59
|
+
- lib/grit/git-ruby.rb
|
60
60
|
- lib/grit/git-ruby/commit_db.rb
|
61
61
|
- lib/grit/git-ruby/file_index.rb
|
62
62
|
- lib/grit/git-ruby/git_object.rb
|
63
|
-
- lib/grit/git-ruby/internal
|
64
63
|
- lib/grit/git-ruby/internal/file_window.rb
|
65
64
|
- lib/grit/git-ruby/internal/loose.rb
|
66
65
|
- lib/grit/git-ruby/internal/pack.rb
|
67
66
|
- lib/grit/git-ruby/internal/raw_object.rb
|
68
67
|
- lib/grit/git-ruby/object.rb
|
69
68
|
- lib/grit/git-ruby/repository.rb
|
70
|
-
- lib/grit/git-ruby.rb
|
71
69
|
- lib/grit/git.rb
|
72
70
|
- lib/grit/index.rb
|
73
71
|
- lib/grit/lazy.rb
|
@@ -79,14 +77,14 @@ files:
|
|
79
77
|
- lib/grit/submodule.rb
|
80
78
|
- lib/grit/tag.rb
|
81
79
|
- lib/grit/tree.rb
|
82
|
-
- lib/grit.rb
|
83
80
|
- lib/open3_detach.rb
|
84
81
|
- LICENSE
|
85
82
|
has_rdoc: true
|
86
83
|
homepage: http://github.com/mojombo/grit
|
84
|
+
licenses: []
|
85
|
+
|
87
86
|
post_install_message:
|
88
87
|
rdoc_options:
|
89
|
-
- --inline-source
|
90
88
|
- --charset=UTF-8
|
91
89
|
require_paths:
|
92
90
|
- lib
|
@@ -105,9 +103,41 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
103
|
requirements: []
|
106
104
|
|
107
105
|
rubyforge_project: grit
|
108
|
-
rubygems_version: 1.3.
|
106
|
+
rubygems_version: 1.3.5
|
109
107
|
signing_key:
|
110
|
-
specification_version:
|
108
|
+
specification_version: 3
|
111
109
|
summary: Grit is a Ruby library for extracting information from a git repository in an object oriented manner.
|
112
|
-
test_files:
|
113
|
-
|
110
|
+
test_files:
|
111
|
+
- test/bench/benchmarks.rb
|
112
|
+
- test/helper.rb
|
113
|
+
- test/profile.rb
|
114
|
+
- test/suite.rb
|
115
|
+
- test/test_actor.rb
|
116
|
+
- test/test_blame.rb
|
117
|
+
- test/test_blame_tree.rb
|
118
|
+
- test/test_blob.rb
|
119
|
+
- test/test_commit.rb
|
120
|
+
- test/test_commit_stats.rb
|
121
|
+
- test/test_commit_write.rb
|
122
|
+
- test/test_config.rb
|
123
|
+
- test/test_diff.rb
|
124
|
+
- test/test_file_index.rb
|
125
|
+
- test/test_git.rb
|
126
|
+
- test/test_grit.rb
|
127
|
+
- test/test_head.rb
|
128
|
+
- test/test_index_status.rb
|
129
|
+
- test/test_merge.rb
|
130
|
+
- test/test_raw.rb
|
131
|
+
- test/test_real.rb
|
132
|
+
- test/test_reality.rb
|
133
|
+
- test/test_remote.rb
|
134
|
+
- test/test_repo.rb
|
135
|
+
- test/test_rubygit.rb
|
136
|
+
- test/test_rubygit_alt.rb
|
137
|
+
- test/test_rubygit_index.rb
|
138
|
+
- test/test_rubygit_iv2.rb
|
139
|
+
- test/test_submodule.rb
|
140
|
+
- test/test_tag.rb
|
141
|
+
- test/test_tree.rb
|
142
|
+
- examples/ex_add_commit.rb
|
143
|
+
- examples/ex_index.rb
|