@@ -6,7 +6,7 @@ class TestObject < Test::Unit::TestCase
6
6
def setup
7
7
set_file_paths
8
8
@git = Git . open ( @wdir )
9
-
9
+
10
10
@commit = @git . gcommit ( '1cc8667014381' )
11
11
@tree = @git . gtree ( '1cc8667014381^{tree}' )
12
12
@blob = @git . gblob ( 'v2.5:example.txt' )
@@ -18,13 +18,13 @@ def test_sha_state
18
18
o . date
19
19
assert_equal ( original_sha , o . sha )
20
20
end
21
-
21
+
22
22
def test_commit
23
23
o = @git . gcommit ( '1cc8667014381' )
24
24
assert ( o . is_a? ( Git ::Object ::Commit ) )
25
25
assert ( o . commit? )
26
26
assert ( !o . tag? )
27
-
27
+
28
28
assert_equal ( '94c827875e2cadb8bc8d4cdd900f19aa9e8634c7' , o . gtree . to_s )
29
29
assert_equal ( '546bec6f8872efa41d5d97a369f669165ecda0de' , o . parent . sha )
30
30
assert_equal ( 1 , o . parents . size )
@@ -36,95 +36,95 @@ def test_commit
36
36
assert_equal ( '11-08-07' , o . committer_date . getutc . strftime ( "%m-%d-%y" ) )
37
37
assert_equal ( '11-08-07' , o . date . getutc . strftime ( "%m-%d-%y" ) )
38
38
assert_equal ( 'test' , o . message )
39
-
39
+
40
40
assert_equal ( 'tags/v2.5' , o . parent . name )
41
- assert_equal ( 'master ' , o . parent . parent . name )
42
- assert_equal ( 'master~1 ' , o . parent . parent . parent . name )
43
-
41
+ assert_equal ( 'tags/v2.5~1 ' , o . parent . parent . name )
42
+ assert_equal ( 'tags/v2.5~2 ' , o . parent . parent . parent . name )
43
+
44
44
o = @git . gcommit ( 'HEAD' )
45
45
assert ( o . is_a? ( Git ::Object ::Commit ) )
46
46
assert ( o . commit? )
47
-
47
+
48
48
o = @git . gcommit ( 'test_object' )
49
49
assert ( o . is_a? ( Git ::Object ::Commit ) )
50
50
assert ( o . commit? )
51
51
end
52
-
52
+
53
53
def test_commit_contents
54
54
o = @git . gcommit ( '1cc8667014381' )
55
55
assert_equal ( 'tree 94c827875e2cadb8bc8d4cdd900f19aa9e8634c7' , o . contents_array [ 0 ] )
56
56
assert_equal ( 'parent 546bec6f8872efa41d5d97a369f669165ecda0de' , o . contents_array [ 1 ] )
57
57
end
58
-
58
+
59
59
def test_object_to_s
60
60
assert_equal ( '1cc8667014381e2788a94777532a788307f38d26' , @commit . sha )
61
61
assert_equal ( '94c827875e2cadb8bc8d4cdd900f19aa9e8634c7' , @tree . sha )
62
62
assert_equal ( 'ba492c62b6227d7f3507b4dcc6e6d5f13790eabf' , @blob . sha )
63
63
end
64
-
64
+
65
65
def test_object_size
66
66
assert_equal ( 265 , @commit . size )
67
67
assert_equal ( 72 , @tree . size )
68
68
assert_equal ( 128 , @blob . size )
69
69
end
70
-
70
+
71
71
def test_tree
72
72
o = @git . gtree ( '1cc8667014381^{tree}' )
73
73
assert ( o . is_a? ( Git ::Object ::Tree ) )
74
74
assert ( o . tree? )
75
-
75
+
76
76
o = @git . gtree ( 'v2.7^{tree}' )
77
-
77
+
78
78
assert_equal ( 2 , o . children . size )
79
79
assert_equal ( 1 , o . blobs . size )
80
80
assert_equal ( 1 , o . subtrees . size )
81
81
assert_equal ( 1 , o . trees [ 'ex_dir' ] . blobs . size )
82
82
83
83
assert_equal ( 2 , o . full_tree . size )
84
84
assert_equal ( "100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\t ex_dir/ex.txt" , o . full_tree . first )
85
-
85
+
86
86
assert_equal ( 2 , o . depth )
87
-
87
+
88
88
o = @git . gtree ( '94c827875e2cadb8bc8d4cdd900f19aa9e8634c7' )
89
89
assert ( o . is_a? ( Git ::Object ::Tree ) )
90
90
assert ( o . tree? )
91
91
end
92
-
92
+
93
93
def test_tree_contents
94
94
o = @git . gtree ( '1cc8667014381^{tree}' )
95
95
assert_equal ( '040000 tree 6b790ddc5eab30f18cabdd0513e8f8dac0d2d3ed ex_dir' , o . contents_array . first )
96
96
end
97
-
97
+
98
98
def test_blob
99
99
o = @git . gblob ( 'ba492c62b6' )
100
100
assert ( o . is_a? ( Git ::Object ::Blob ) )
101
101
assert ( o . blob? )
102
-
102
+
103
103
o = @git . gblob ( 'v2.5:example.txt' )
104
104
assert ( o . is_a? ( Git ::Object ::Blob ) )
105
105
assert ( o . blob? )
106
106
end
107
-
107
+
108
108
def test_blob_contents
109
109
o = @git . gblob ( 'v2.6:example.txt' )
110
110
assert_equal ( 'replace with new text' , o . contents )
111
111
assert_equal ( 'replace with new text' , o . contents ) # this should be cached
112
-
112
+
113
113
# make sure the block is called
114
114
block_called = false
115
115
o . contents do |f |
116
116
block_called = true
117
117
assert_equal ( 'replace with new text' , f . read . chomp )
118
118
end
119
-
119
+
120
120
assert ( block_called )
121
121
end
122
-
122
+
123
123
def test_revparse
124
124
sha = @git . revparse ( 'v2.6:example.txt' )
125
125
assert_equal ( '1f09f2edb9c0d9275d15960771b363ca6940fbe3' , sha )
126
126
end
127
-
127
+
128
128
def test_grep
129
129
g = @git . gtree ( 'a3db7143944dcfa0' ) . grep ( 'search' ) # there
130
130
assert_equal ( 3 , g . to_a . flatten . size )
@@ -135,11 +135,9 @@ def test_grep
135
135
g = @git . gcommit ( 'gitsearch1' ) . grep ( 'search' ) # there
136
136
assert_equal ( 8 , g . to_a . flatten . size )
137
137
assert_equal ( 2 , g . size )
138
-
138
+
139
139
g = @git . gcommit ( 'gitsearch1' ) . grep ( 'search' , 'scott/new*' ) # there
140
140
assert_equal ( 3 , g . to_a . flatten . size )
141
141
assert_equal ( 1 , g . size )
142
142
end
143
-
144
-
145
143
end
0 commit comments