Skip to content

Commit 5d3202e

Browse files
committed
Factor out finding an object into a function
1 parent f958150 commit 5d3202e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Local/Utils.pm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ my $GIT_LS_TREE = qr{
1818
\z
1919
}x;
2020

21-
sub get_blob_iterator {
22-
my ( $tree, $starting_path ) = @_;
21+
sub find_git_object {
22+
my ( $tree, $path ) = @_;
2323

24-
my @paths = split('/', $starting_path);
24+
my @paths = split('/', $path);
2525

2626
while(@paths) {
2727
my $directory = shift @paths;
@@ -49,6 +49,14 @@ sub get_blob_iterator {
4949
}
5050
}
5151

52+
return $tree;
53+
}
54+
55+
sub get_blob_iterator {
56+
my ( $tree, $starting_path ) = @_;
57+
58+
$tree = find_git_object($tree, $starting_path);
59+
5260
open my $pipe, '-|', 'git', 'ls-tree', '-r', $tree;
5361

5462
return sub {
@@ -110,6 +118,6 @@ sub get_folds_for {
110118
return @{ decode_json($contents) };
111119
}
112120

113-
our @EXPORT = qw(get_blob_iterator get_corpus_contents get_html_output_for get_folds_for);
121+
our @EXPORT = qw(get_blob_iterator get_corpus_contents get_html_output_for get_folds_for find_git_object);
114122

115123
1;

0 commit comments

Comments
 (0)