aboutsummaryrefslogtreecommitdiffstats
path: root/lib/LXRng/Repo/Git/Iterator.pm
diff options
context:
space:
mode:
authorArne Georg Gleditsch <argggh@lxr.linpro.no>2007-07-05 00:51:08 +0200
committerArne Georg Gleditsch <argggh@lxr.linpro.no>2007-07-05 00:51:08 +0200
commite9fa4c98bb5f084739d3418ade3f0c51e34a0aa1 (patch)
treefec1d635625e031cde7cba1b0a1d95ee92ac760b /lib/LXRng/Repo/Git/Iterator.pm
Rebase tree.
Diffstat (limited to 'lib/LXRng/Repo/Git/Iterator.pm')
-rw-r--r--lib/LXRng/Repo/Git/Iterator.pm33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/LXRng/Repo/Git/Iterator.pm b/lib/LXRng/Repo/Git/Iterator.pm
new file mode 100644
index 0000000..978e584
--- /dev/null
+++ b/lib/LXRng/Repo/Git/Iterator.pm
@@ -0,0 +1,33 @@
+package LXRng::Repo::Git::Iterator;
+
+use strict;
+use LXRng::Repo::Git::File;
+
+sub new {
+ my ($class, $repo, $release) = @_;
+
+ my @refs;
+ my $git = $repo->_git_cmd('ls-tree', '-r', $release);
+ while (<$git>) {
+ if (/\S+\s+blob\s+(\S+)\s+(\S+)/) {
+ push(@refs, [$2, $1]);
+ }
+ }
+ close($git);
+
+ return bless({refs => \@refs, repo => $repo, rel => $release}, $class);
+}
+
+sub next {
+ my ($self) = @_;
+
+ return undef unless @{$$self{'refs'}} > 0;
+ my $file = shift(@{$$self{'refs'}});
+
+ return LXRng::Repo::Git::File->new($$self{'repo'},
+ $$file[0],
+ $$file[1],
+ $$self{'rel'});
+}
+
+1;