grit 1.0.1 → 1.1.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 +32 -2
- data/README.md +210 -0
- data/VERSION.yml +2 -2
- data/lib/grit.rb +11 -4
- data/lib/grit/blob.rb +11 -2
- data/lib/grit/commit.rb +41 -33
- data/lib/grit/commit_stats.rb +26 -2
- data/lib/grit/diff.rb +6 -6
- data/lib/grit/git-ruby.rb +1 -1
- data/lib/grit/git-ruby/git_object.rb +9 -3
- data/lib/grit/git-ruby/internal/{mmap.rb → file_window.rb} +2 -2
- data/lib/grit/git-ruby/internal/loose.rb +6 -6
- data/lib/grit/git-ruby/internal/pack.rb +19 -19
- data/lib/grit/git-ruby/object.rb +8 -2
- data/lib/grit/git-ruby/repository.rb +5 -6
- data/lib/grit/git.rb +14 -8
- data/lib/grit/index.rb +2 -2
- data/lib/grit/ref.rb +4 -6
- data/lib/grit/repo.rb +25 -3
- data/lib/grit/ruby1.9.rb +7 -0
- data/lib/grit/submodule.rb +5 -1
- data/lib/grit/tag.rb +61 -66
- data/lib/grit/tree.rb +20 -1
- data/test/dot_git/objects/b7/f932bd02b3e0a4228ee7b55832749028d345de +1 -0
- data/test/dot_git/packed-refs +2 -1
- data/test/dot_git/refs/tags/annotated +1 -0
- data/test/dot_git/refs/tags/not_annotated +1 -0
- data/test/fixtures/rev_list_delta_a +8 -0
- data/test/fixtures/rev_list_delta_b +11 -0
- data/test/fixtures/show_cc +637 -0
- data/test/helper.rb +1 -0
- data/test/test_blob.rb +18 -14
- data/test/test_commit.rb +65 -48
- data/test/test_git.rb +21 -1
- data/test/test_repo.rb +26 -0
- data/test/test_rubygit.rb +7 -2
- data/test/test_submodule.rb +18 -0
- data/test/test_tag.rb +53 -11
- data/test/test_tree.rb +5 -0
- metadata +11 -4
- data/README.txt +0 -222
data/test/helper.rb
CHANGED
data/test/test_blob.rb
CHANGED
@@ -5,51 +5,50 @@ class TestBlob < Test::Unit::TestCase
|
|
5
5
|
@r = Repo.new(GRIT_REPO)
|
6
6
|
@b = Blob.allocate
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
# blob
|
10
10
|
def test_nosuch_blob
|
11
11
|
t = @r.blob('blahblah')
|
12
|
-
puts t.data
|
13
12
|
assert t.is_a?(Blob)
|
14
13
|
end
|
15
|
-
|
14
|
+
|
16
15
|
def test_data_should_return_blob_contents
|
17
16
|
Git.any_instance.expects(:cat_file).returns(fixture('cat_file_blob'))
|
18
17
|
blob = Blob.create(@r, :id => 'abc')
|
19
18
|
assert_equal "Hello world", blob.data
|
20
19
|
end
|
21
|
-
|
20
|
+
|
22
21
|
def test_data_should_cache
|
23
22
|
Git.any_instance.expects(:cat_file).returns(fixture('cat_file_blob')).times(1)
|
24
23
|
blob = Blob.create(@r, :id => 'abc')
|
25
24
|
blob.data
|
26
25
|
blob.data
|
27
26
|
end
|
28
|
-
|
27
|
+
|
29
28
|
# size
|
30
|
-
|
29
|
+
|
31
30
|
def test_size_should_return_file_size
|
32
31
|
Git.any_instance.expects(:cat_file).returns(fixture('cat_file_blob_size'))
|
33
32
|
blob = Blob.create(@r, :id => 'abc')
|
34
33
|
assert_equal 11, blob.size
|
35
34
|
end
|
36
|
-
|
35
|
+
|
37
36
|
# data
|
38
|
-
|
37
|
+
|
39
38
|
# mime_type
|
40
|
-
|
39
|
+
|
41
40
|
def test_mime_type_should_return_mime_type_for_known_types
|
42
41
|
blob = Blob.create(@r, :id => 'abc', :name => 'foo.png')
|
43
42
|
assert_equal "image/png", blob.mime_type
|
44
43
|
end
|
45
|
-
|
44
|
+
|
46
45
|
def test_mime_type_should_return_text_plain_for_unknown_types
|
47
46
|
blob = Blob.create(@r, :id => 'abc')
|
48
47
|
assert_equal "text/plain", blob.mime_type
|
49
48
|
end
|
50
|
-
|
49
|
+
|
51
50
|
# blame
|
52
|
-
|
51
|
+
|
53
52
|
def test_blame
|
54
53
|
Git.any_instance.expects(:blame).returns(fixture('blame'))
|
55
54
|
b = Blob.blame(@r, 'master', 'lib/grit.rb')
|
@@ -69,11 +68,16 @@ class TestBlob < Test::Unit::TestCase
|
|
69
68
|
# c.expects(:__bake__).times(1)
|
70
69
|
# assert_equal Tree, c.tree.class
|
71
70
|
end
|
72
|
-
|
71
|
+
|
73
72
|
# inspect
|
74
|
-
|
73
|
+
|
75
74
|
def test_inspect
|
76
75
|
@b = Blob.create(@r, :id => 'abc')
|
77
76
|
assert_equal %Q{#<Grit::Blob "abc">}, @b.inspect
|
78
77
|
end
|
78
|
+
|
79
|
+
def test_basename
|
80
|
+
@b = Blob.create(@r, :name => 'foo/bar.rb')
|
81
|
+
assert_equal "bar.rb", @b.basename
|
82
|
+
end
|
79
83
|
end
|
data/test/test_commit.rb
CHANGED
@@ -4,78 +4,78 @@ class TestCommit < Test::Unit::TestCase
|
|
4
4
|
def setup
|
5
5
|
@r = Repo.new(File.join(File.dirname(__FILE__), *%w[dot_git]), :is_bare => true)
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
# __bake__
|
9
|
-
|
9
|
+
|
10
10
|
def test_bake
|
11
11
|
Git.any_instance.expects(:rev_list).returns(fixture('rev_list_single'))
|
12
12
|
@c = Commit.create(@r, :id => '4c8124ffcf4039d292442eeccabdeca5af5c5017')
|
13
13
|
@c.author # bake
|
14
|
-
|
14
|
+
|
15
15
|
assert_equal "Tom Preston-Werner", @c.author.name
|
16
16
|
assert_equal "tom@mojombo.com", @c.author.email
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
# short_name
|
20
|
-
|
20
|
+
|
21
21
|
def test_id_abbrev
|
22
22
|
assert_equal '80f136f', @r.commit('80f136f500dfdb8c3e8abf4ae716f875f0a1b57f').id_abbrev
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
# count
|
26
|
-
|
26
|
+
|
27
27
|
def test_count
|
28
28
|
assert_equal 107, Commit.count(@r, 'master')
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
# diff
|
32
|
-
|
32
|
+
|
33
33
|
def test_diff
|
34
34
|
# git diff --full-index 91169e1f5fa4de2eaea3f176461f5dc784796769 > test/fixtures/diff_p
|
35
|
-
|
35
|
+
|
36
36
|
Git.any_instance.expects(:diff).with({:full_index => true}, 'master').returns(fixture('diff_p'))
|
37
37
|
diffs = Commit.diff(@r, 'master')
|
38
|
-
|
38
|
+
|
39
39
|
assert_equal 15, diffs.size
|
40
|
-
|
40
|
+
|
41
41
|
assert_equal '.gitignore', diffs.first.a_path
|
42
42
|
assert_equal '.gitignore', diffs.first.b_path
|
43
|
-
assert_equal '4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs.first.
|
44
|
-
assert_equal '2dd02534615434d88c51307beb0f0092f21fd103', diffs.first.
|
43
|
+
assert_equal '4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs.first.a_blob.id
|
44
|
+
assert_equal '2dd02534615434d88c51307beb0f0092f21fd103', diffs.first.b_blob.id
|
45
45
|
assert_equal '100644', diffs.first.b_mode
|
46
46
|
assert_equal false, diffs.first.new_file
|
47
47
|
assert_equal false, diffs.first.deleted_file
|
48
48
|
assert_equal "--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs.first.diff
|
49
|
-
|
49
|
+
|
50
50
|
assert_equal 'lib/grit/actor.rb', diffs[5].a_path
|
51
|
-
assert_equal nil, diffs[5].
|
52
|
-
assert_equal 'f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].
|
51
|
+
assert_equal nil, diffs[5].a_blob
|
52
|
+
assert_equal 'f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id
|
53
53
|
assert_equal true, diffs[5].new_file
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def test_diff_with_two_commits
|
57
57
|
# git diff --full-index 59ddc32 13d27d5 > test/fixtures/diff_2
|
58
58
|
Git.any_instance.expects(:diff).with({:full_index => true}, '59ddc32', '13d27d5').returns(fixture('diff_2'))
|
59
59
|
diffs = Commit.diff(@r, '59ddc32', '13d27d5')
|
60
|
-
|
60
|
+
|
61
61
|
assert_equal 3, diffs.size
|
62
62
|
assert_equal %w(lib/grit/commit.rb test/fixtures/show_empty_commit test/test_commit.rb), diffs.collect { |d| d.a_path }
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
def test_diff_with_files
|
66
66
|
# git diff --full-index 59ddc32 -- lib > test/fixtures/diff_f
|
67
67
|
Git.any_instance.expects(:diff).with({:full_index => true}, '59ddc32', '--', 'lib').returns(fixture('diff_f'))
|
68
68
|
diffs = Commit.diff(@r, '59ddc32', %w(lib))
|
69
|
-
|
69
|
+
|
70
70
|
assert_equal 1, diffs.size
|
71
71
|
assert_equal 'lib/grit/diff.rb', diffs.first.a_path
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
def test_diff_with_two_commits_and_files
|
75
75
|
# git diff --full-index 59ddc32 13d27d5 -- lib > test/fixtures/diff_2f
|
76
76
|
Git.any_instance.expects(:diff).with({:full_index => true}, '59ddc32', '13d27d5', '--', 'lib').returns(fixture('diff_2f'))
|
77
77
|
diffs = Commit.diff(@r, '59ddc32', '13d27d5', %w(lib))
|
78
|
-
|
78
|
+
|
79
79
|
assert_equal 1, diffs.size
|
80
80
|
assert_equal 'lib/grit/commit.rb', diffs.first.a_path
|
81
81
|
end
|
@@ -83,25 +83,25 @@ class TestCommit < Test::Unit::TestCase
|
|
83
83
|
# diffs
|
84
84
|
def test_diffs
|
85
85
|
# git diff --full-index 91169e1f5fa4de2eaea3f176461f5dc784796769 > test/fixtures/diff_p
|
86
|
-
|
86
|
+
|
87
87
|
Git.any_instance.expects(:diff).returns(fixture('diff_p'))
|
88
88
|
@c = Commit.create(@r, :id => '91169e1f5fa4de2eaea3f176461f5dc784796769')
|
89
89
|
diffs = @c.diffs
|
90
|
-
|
90
|
+
|
91
91
|
assert_equal 15, diffs.size
|
92
|
-
|
92
|
+
|
93
93
|
assert_equal '.gitignore', diffs.first.a_path
|
94
94
|
assert_equal '.gitignore', diffs.first.b_path
|
95
|
-
assert_equal '4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs.first.
|
96
|
-
assert_equal '2dd02534615434d88c51307beb0f0092f21fd103', diffs.first.
|
95
|
+
assert_equal '4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs.first.a_blob.id
|
96
|
+
assert_equal '2dd02534615434d88c51307beb0f0092f21fd103', diffs.first.b_blob.id
|
97
97
|
assert_equal '100644', diffs.first.b_mode
|
98
98
|
assert_equal false, diffs.first.new_file
|
99
99
|
assert_equal false, diffs.first.deleted_file
|
100
100
|
assert_equal "--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs.first.diff
|
101
|
-
|
101
|
+
|
102
102
|
assert_equal 'lib/grit/actor.rb', diffs[5].a_path
|
103
|
-
assert_equal nil, diffs[5].
|
104
|
-
assert_equal 'f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].
|
103
|
+
assert_equal nil, diffs[5].a_blob
|
104
|
+
assert_equal 'f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id
|
105
105
|
assert_equal true, diffs[5].new_file
|
106
106
|
end
|
107
107
|
|
@@ -111,56 +111,73 @@ class TestCommit < Test::Unit::TestCase
|
|
111
111
|
Git.any_instance.expects(:show).with({:full_index => true, :pretty => 'raw'}, '634396b2f541a9f2d58b00be1a07f0c358b999b3').returns(fixture('diff_i'))
|
112
112
|
@c = Commit.create(@r, :id => '634396b2f541a9f2d58b00be1a07f0c358b999b3')
|
113
113
|
diffs = @c.diffs
|
114
|
-
|
114
|
+
|
115
115
|
assert_equal 10, diffs.size
|
116
|
-
|
116
|
+
|
117
117
|
assert_equal 'History.txt', diffs.first.a_path
|
118
118
|
assert_equal 'History.txt', diffs.first.b_path
|
119
|
-
assert_equal nil, diffs.first.
|
119
|
+
assert_equal nil, diffs.first.a_blob
|
120
120
|
assert_equal nil, diffs.first.b_mode
|
121
|
-
assert_equal '81d2c27608b352814cbe979a6acd678d30219678', diffs.first.
|
121
|
+
assert_equal '81d2c27608b352814cbe979a6acd678d30219678', diffs.first.b_blob.id
|
122
122
|
assert_equal true, diffs.first.new_file
|
123
123
|
assert_equal false, diffs.first.deleted_file
|
124
124
|
assert_equal "--- /dev/null\n+++ b/History.txt\n@@ -0,0 +1,5 @@\n+== 1.0.0 / 2007-10-09\n+\n+* 1 major enhancement\n+ * Birthday!\n+", diffs.first.diff
|
125
125
|
|
126
|
-
|
126
|
+
|
127
127
|
assert_equal 'lib/grit.rb', diffs[5].a_path
|
128
|
-
assert_equal nil, diffs[5].
|
129
|
-
assert_equal '32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].
|
128
|
+
assert_equal nil, diffs[5].a_blob
|
129
|
+
assert_equal '32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_blob.id
|
130
130
|
assert_equal true, diffs[5].new_file
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
def test_diffs_on_initial_import_with_empty_commit
|
134
134
|
Git.any_instance.expects(:show).with(
|
135
|
-
{:full_index => true, :pretty => 'raw'},
|
135
|
+
{:full_index => true, :pretty => 'raw'},
|
136
136
|
'634396b2f541a9f2d58b00be1a07f0c358b999b3'
|
137
137
|
).returns(fixture('show_empty_commit'))
|
138
|
-
|
138
|
+
|
139
139
|
@c = Commit.create(@r, :id => '634396b2f541a9f2d58b00be1a07f0c358b999b3')
|
140
140
|
diffs = @c.diffs
|
141
|
-
|
141
|
+
|
142
142
|
assert_equal [], diffs
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
def test_diffs_with_mode_only_change
|
146
146
|
Git.any_instance.expects(:diff).returns(fixture('diff_mode_only'))
|
147
147
|
@c = Commit.create(@r, :id => '91169e1f5fa4de2eaea3f176461f5dc784796769')
|
148
148
|
diffs = @c.diffs
|
149
|
-
|
149
|
+
|
150
150
|
assert_equal 23, diffs.size
|
151
151
|
assert_equal '100644', diffs[0].a_mode
|
152
152
|
assert_equal '100755', diffs[0].b_mode
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
# to_s
|
156
|
-
|
156
|
+
|
157
157
|
def test_to_s
|
158
158
|
@c = Commit.create(@r, :id => 'abc')
|
159
159
|
assert_equal "abc", @c.to_s
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
|
+
# to_patch
|
163
|
+
|
164
|
+
def test_to_patch
|
165
|
+
@c = Commit.create(@r, :id => '80f136f500dfdb8c3e8abf4ae716f875f0a1b57f')
|
166
|
+
|
167
|
+
patch = @c.to_patch
|
168
|
+
|
169
|
+
assert patch.include?('From 80f136f500dfdb8c3e8abf4ae716f875f0a1b57f Mon Sep 17 00:00:00 2001')
|
170
|
+
assert patch.include?('From: tom <tom@taco.(none)>')
|
171
|
+
assert patch.include?('Date: Tue, 20 Nov 2007 17:27:42 -0800')
|
172
|
+
assert patch.include?('Subject: [PATCH] fix tests on other machines')
|
173
|
+
assert patch.include?('test/test_reality.rb | 30 +++++++++++++++---------------')
|
174
|
+
assert patch.include?('@@ -1,17 +1,17 @@')
|
175
|
+
assert patch.include?('+# recurse(t)')
|
176
|
+
assert patch.include?("1.6.")
|
177
|
+
end
|
178
|
+
|
162
179
|
# inspect
|
163
|
-
|
180
|
+
|
164
181
|
def test_inspect
|
165
182
|
@c = Commit.create(@r, :id => 'abc')
|
166
183
|
assert_equal %Q{#<Grit::Commit "abc">}, @c.inspect
|
data/test/test_git.rb
CHANGED
@@ -55,10 +55,30 @@ class TestGit < Test::Unit::TestCase
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_raises_on_slow_shell
|
58
|
-
Grit::Git.git_timeout = 0.
|
58
|
+
Grit::Git.git_timeout = 0.0000001
|
59
59
|
assert_raises Grit::Git::GitTimeout do
|
60
60
|
@git.version
|
61
61
|
end
|
62
62
|
Grit::Git.git_timeout = 5.0
|
63
63
|
end
|
64
|
+
|
65
|
+
def test_it_really_shell_escapes_arguments_to_the_git_shell
|
66
|
+
@git.expects(:sh).with("#{Git.git_binary} --git-dir='#{@git.git_dir}' foo --bar='bazz\\'er'")
|
67
|
+
@git.foo(:bar => "bazz'er")
|
68
|
+
@git.expects(:sh).with("#{Git.git_binary} --git-dir='#{@git.git_dir}' bar -x 'quu\\'x'")
|
69
|
+
@git.bar(:x => "quu'x")
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_it_shell_escapes_the_standalone_argument
|
73
|
+
@git.expects(:sh).with("#{Git.git_binary} --git-dir='#{@git.git_dir}' foo 'bar\\'s'")
|
74
|
+
@git.foo({}, "bar's")
|
75
|
+
|
76
|
+
@git.expects(:sh).with("#{Git.git_binary} --git-dir='#{@git.git_dir}' foo 'bar' '\\; echo \\'noooo\\''")
|
77
|
+
@git.foo({}, "bar", "; echo 'noooo'")
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_piping_should_work_on_1_9
|
81
|
+
@git.expects(:sh).with("#{Git.git_binary} --git-dir='#{@git.git_dir}' archive 'master' | gzip")
|
82
|
+
@git.archive({}, "master", "| gzip")
|
83
|
+
end
|
64
84
|
end
|
data/test/test_repo.rb
CHANGED
@@ -318,4 +318,30 @@ class TestRepo < Test::Unit::TestCase
|
|
318
318
|
Git.any_instance.expects(:log).with({:pretty => 'raw', :max_count => 1}, 'master', '--', 'file.rb').returns(fixture('rev_list'))
|
319
319
|
@r.log('master', 'file.rb', :max_count => 1)
|
320
320
|
end
|
321
|
+
|
322
|
+
# commit_deltas_from
|
323
|
+
|
324
|
+
def test_commit_deltas_from_nothing_new
|
325
|
+
other_repo = Repo.new(GRIT_REPO)
|
326
|
+
@r.git.expects(:rev_list).with({}, "master").returns(fixture("rev_list_delta_b"))
|
327
|
+
other_repo.git.expects(:rev_list).with({}, "master").returns(fixture("rev_list_delta_a"))
|
328
|
+
|
329
|
+
delta_blobs = @r.commit_deltas_from(other_repo)
|
330
|
+
assert_equal 0, delta_blobs.size
|
331
|
+
end
|
332
|
+
|
333
|
+
def test_commit_deltas_from_when_other_has_new
|
334
|
+
other_repo = Repo.new(GRIT_REPO)
|
335
|
+
@r.git.expects(:rev_list).with({}, "master").returns(fixture("rev_list_delta_a"))
|
336
|
+
other_repo.git.expects(:rev_list).with({}, "master").returns(fixture("rev_list_delta_b"))
|
337
|
+
%w[
|
338
|
+
4c8124ffcf4039d292442eeccabdeca5af5c5017
|
339
|
+
634396b2f541a9f2d58b00be1a07f0c358b999b3
|
340
|
+
ab25fd8483882c3bda8a458ad2965d2248654335
|
341
|
+
].each do |ref|
|
342
|
+
Commit.expects(:find_all).with(other_repo, ref, :max_count => 1).returns([stub()])
|
343
|
+
end
|
344
|
+
delta_blobs = @r.commit_deltas_from(other_repo)
|
345
|
+
assert_equal 3, delta_blobs.size
|
346
|
+
end
|
321
347
|
end
|
data/test/test_rubygit.rb
CHANGED
@@ -87,17 +87,22 @@ class TestRubyGit < Test::Unit::TestCase
|
|
87
87
|
out = @git.cat_file({:s => true}, @tree_sha)
|
88
88
|
assert_equal '252', out
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def test_ls_tree
|
92
92
|
out = @git.ls_tree({}, @tree_sha)
|
93
93
|
assert_equal out, fixture('cat_file_tree_ruby').chomp
|
94
94
|
end
|
95
95
|
|
96
|
+
def test_ls_tree_with_blobs
|
97
|
+
out = @git.ls_tree({}, @blob_sha)
|
98
|
+
assert_equal out, nil
|
99
|
+
end
|
100
|
+
|
96
101
|
def test_ls_tree_treeish
|
97
102
|
out = @git.ls_tree({}, 'testing')
|
98
103
|
assert_equal out, fixture('cat_file_tree_ruby').chomp
|
99
104
|
end
|
100
|
-
|
105
|
+
|
101
106
|
def test_ls_tree_paths
|
102
107
|
paths = ['History.txt', 'lib']
|
103
108
|
out = @git.ls_tree({}, @tree_sha, paths)
|
data/test/test_submodule.rb
CHANGED
@@ -21,6 +21,19 @@ class TestSubmodule < Test::Unit::TestCase
|
|
21
21
|
assert_equal "git://github.com/mojombo/god", config['god']['url']
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_config_with_windows_lineendings
|
25
|
+
data = fixture('gitmodules').gsub(/\n/, "\r\n")
|
26
|
+
blob = stub(:data => data, :id => 'abc')
|
27
|
+
tree = stub(:'/' => blob)
|
28
|
+
commit = stub(:tree => tree)
|
29
|
+
repo = stub(:commit => commit)
|
30
|
+
|
31
|
+
config = Submodule.config(repo)
|
32
|
+
|
33
|
+
assert_equal "git://github.com/mojombo/glowstick", config['test/glowstick']['url']
|
34
|
+
assert_equal "git://github.com/mojombo/god", config['god']['url']
|
35
|
+
end
|
36
|
+
|
24
37
|
def test_no_config
|
25
38
|
tree = stub(:'/' => nil)
|
26
39
|
commit = stub(:tree => tree)
|
@@ -48,4 +61,9 @@ class TestSubmodule < Test::Unit::TestCase
|
|
48
61
|
@t = Submodule.create(@r, :id => 'abc')
|
49
62
|
assert_equal %Q{#<Grit::Submodule "abc">}, @t.inspect
|
50
63
|
end
|
64
|
+
|
65
|
+
def test_basename
|
66
|
+
@submodule = Submodule.create(@r, :name => 'foo/bar')
|
67
|
+
assert_equal "bar", @submodule.basename
|
68
|
+
end
|
51
69
|
end
|
data/test/test_tag.rb
CHANGED
@@ -4,22 +4,64 @@ class TestTag < Test::Unit::TestCase
|
|
4
4
|
def setup
|
5
5
|
@r = Repo.new(File.join(File.dirname(__FILE__), *%w[dot_git]), :is_bare => true)
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
|
+
# list_from_string size
|
9
|
+
|
10
|
+
def test_list_from_string_size
|
11
|
+
assert_equal 5, @r.tags.size
|
12
|
+
end
|
13
|
+
|
8
14
|
# list_from_string
|
9
|
-
|
15
|
+
|
10
16
|
def test_list_from_string
|
11
|
-
|
12
|
-
|
13
|
-
assert_equal
|
14
|
-
assert_equal '
|
15
|
-
|
17
|
+
tag = @r.tags[1]
|
18
|
+
|
19
|
+
assert_equal 'not_annotated', tag.name
|
20
|
+
assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', tag.commit.id
|
21
|
+
end
|
22
|
+
|
23
|
+
# list_from_string_for_signed_tag
|
24
|
+
|
25
|
+
def test_list_from_string_for_signed_tag
|
26
|
+
tag = @r.tags[2]
|
27
|
+
|
28
|
+
assert_equal 'v0.7.0', tag.name
|
29
|
+
assert_equal '7bcc0ee821cdd133d8a53e8e7173a334fef448aa', tag.commit.id
|
30
|
+
end
|
31
|
+
|
32
|
+
# list_from_string_for_annotated_tag
|
33
|
+
|
34
|
+
def test_list_from_string_for_annotated_tag
|
35
|
+
tag = @r.tags.first
|
36
|
+
|
37
|
+
assert_equal 'annotated', tag.name
|
38
|
+
assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', tag.commit.id
|
39
|
+
end
|
40
|
+
|
41
|
+
# list_from_string_for_packed_tag
|
42
|
+
|
43
|
+
def test_list_from_string_for_packed_tag
|
44
|
+
tag = @r.tags[4]
|
45
|
+
|
46
|
+
assert_equal 'packed', tag.name
|
47
|
+
assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', tag.commit.id
|
48
|
+
end
|
49
|
+
|
50
|
+
# list_from_string_for_packed_annotated_tag
|
51
|
+
|
52
|
+
def test_list_from_string_for_packed_annotated_tag
|
53
|
+
tag = @r.tags[3]
|
54
|
+
|
55
|
+
assert_equal 'packed_annotated', tag.name
|
56
|
+
assert_equal '7bcc0ee821cdd133d8a53e8e7173a334fef448aa', tag.commit.id
|
16
57
|
end
|
17
|
-
|
58
|
+
|
59
|
+
|
18
60
|
# inspect
|
19
|
-
|
61
|
+
|
20
62
|
def test_inspect
|
21
|
-
tag = @r.tags.
|
22
|
-
|
63
|
+
tag = @r.tags.last
|
64
|
+
|
23
65
|
assert_equal %Q{#<Grit::Tag "#{tag.name}">}, tag.inspect
|
24
66
|
end
|
25
67
|
end
|