Git::R...erator(3pm)

πŸ“¦
version 1.314 Β· 2 versions
  • 1.314 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.314 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Git::Repository::Log::Iterator β€” the manual, but make it cute

okay bestie, welcome to Git::Repository::Log::Iterator(3pm) πŸ’… this one's a Perl module page from the User Contributed Perl Documentation, and it's literally the little machine that takes a big ol' git log stream and ✨ chops it into records ✨ for you.


🌸 NAME 🌸

Git::Repository::Log::Iterator β€” split a git log stream into records. that's it, that's the whole job, and she does it flawlessly no cap πŸŽ€


✨ SYNOPSIS ✨

use Git::Repository::Log::Iterator;

# use a default Git::Repository context
my $iter = Git::Repository::Log::Iterator->new('HEAD~10..');

# or provide an existing instance
my $iter = Git::Repository::Log::Iterator->new( $r, 'HEAD~10..' );

# get the next log record
while ( my $log = $iter->next ) {
    ...;
}

look at her go πŸ¦‹ two ways to spin her up, one little while loop, and you're eating good.


πŸ’œ DESCRIPTION πŸ’œ

Git::Repository::Log::Iterator kicks off a git log command from a list of parameters and then parses the output to produce Git::Repository::Log objects, one per log item. it's giving factory energy, honestly πŸ‘‘


πŸ‘‘ METHODS πŸ‘‘

πŸ“ new

my $iter = Git::Repository::Log::Iterator->new( @args );

creates a brand new git log stream from the parameter list in @args and hands you back an iterator on top of it. slay.

new() will happily accept any parameters β€” she's not picky β€” but heads up: Git::Repository::Log::Iterator expects the output to look like the output of --pretty=raw, so she forces the --pretty option, just in case format.pretty is defined in the Git configuration. and she also forcibly removes colored output with --color=never. no rainbow logs here, sorry, she needs it plain 🧚

extra output (like patches) gets stashed in the extra parameter of the Git::Repository::Log object. decorations? lost. gone. rip πŸͺ¦

and if new() spots unsupported options in the parameter list, she will croak() at you with a message advising you to use run( 'log' => ... ) and parse the output yourself. she's not mad, she's just setting a boundary πŸ’€

the object is really just a blessed hash reference with only two keys:

  • cmd β€” the Git::Repository::Command object running the actual git log command. it might not be defined in some cases (see below, new_from_fh and new_from_file).
  • fh β€” the filehandle from which the output of git log is actually read. this is the only attribute needed to run the next method.

🌈 new_from_fh

this constructor makes it possible to provide the filehandle directly. you bring the fh, she brings the parsing 🫢

the cmd key is not defined when you use this constructor.

πŸŽ€ new_from_file

this constructor makes it possible to provide a filename that will be open()ed to produce a filehandle, so you can read the log stream from it.

the cmd key is not defined when you use this constructor either. same vibe, different input.

⭐ next

my $log = $iter->next;

returns the next log item as a Git::Repository::Log object β€” or nothing at all if the stream has ended. periodt. πŸ’«


Copyright 2010-2016 Philippe Bruhat (BooK), all rights reserved.


🌟 LICENSE 🌟

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


ok that's the whole page, bestie, you're officially fluent in log iteration 🧚✨

and that's a wrap on this lil readme β€” this cutie came to you via perl v5.34.0, dated 2022-06-14, under the name Git::R...erator(3pm). mwah πŸ’‹ go split some streams.

πŸ“¦ where this page comes from