File tree 3 files changed +21
-0
lines changed
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,14 @@ def ls_tree(sha)
181
181
182
182
data
183
183
end
184
+
185
+ def full_tree ( sha )
186
+ command_lines ( 'ls-tree' , [ '-r' , sha . to_s ] )
187
+ end
188
+
189
+ def tree_depth ( sha )
190
+ full_tree ( sha ) . size
191
+ end
184
192
185
193
def branches_all
186
194
head = File . read ( File . join ( @git_dir , 'HEAD' ) )
Original file line number Diff line number Diff line change @@ -124,6 +124,14 @@ def trees
124
124
alias_method :subtrees , :trees
125
125
alias_method :subdirectories , :trees
126
126
127
+ def full_tree
128
+ @base . lib . full_tree ( @objectish )
129
+ end
130
+
131
+ def depth
132
+ @base . lib . tree_depth ( @objectish )
133
+ end
134
+
127
135
private
128
136
129
137
def setup
Original file line number Diff line number Diff line change @@ -72,6 +72,11 @@ def test_tree
72
72
assert_equal ( 1 , o . blobs . size )
73
73
assert_equal ( 1 , o . subtrees . size )
74
74
assert_equal ( 1 , o . trees [ 'ex_dir' ] . blobs . size )
75
+
76
+ assert_equal ( 2 , o . full_tree . size )
77
+ assert_equal ( "100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\t ex_dir/ex.txt" , o . full_tree . first )
78
+
79
+ assert_equal ( 2 , o . depth )
75
80
76
81
o = @git . gtree ( '94c827875e2cadb8bc8d4cdd900f19aa9e8634c7' )
77
82
assert ( o . is_a? ( Git ::Object ::Tree ) )
You can’t perform that action at this time.
0 commit comments