AnyEvent-Git-Wrapper
view release on metacpan or search on metacpan
NAME
AnyEvent::Git::Wrapper - Wrap git command-line interface without
blocking
VERSION
version 0.10
SYNOPSIS
use AnyEvent::Git::Wrapper;
# add all files and make a commit...
my $git = AnyEvent::Git::Wrapper->new($dir);
$git->add('.', sub {
$git->commit({ message => 'initial commit' }, sub {
say "made initial commit";
});
});
DESCRIPTION
DEPRECATED: May go away at some point.
This module provides a non-blocking and blocking API for git in the
style and using the data structures of Git::Wrapper. For methods that
execute the git binary, if the last argument is either a code reference
or an AnyEvent condition variable, then the command is run in
non-blocking mode and the result will be sent to the condition variable
when the command completes. For most commands (all those but status,
log and version), the result comes back via the recv method on the
condition variable as two array references, one representing the
standard out and the other being the standard error. Because recv will
return just the first value if called in scalar context, you can
retrieve just the output by calling recv in scalar context.
# ignoring stderr
$git->branch(sub {
my $out = shift->recv;
foreach my $line (@$out)
{
...
}
});
# same thing, but saving stderr
$git->branch(sub {
my($out, $err) = shit->recv;
foreach my $line(@$out)
{
...
}
});
Like Git::Wrapper, you can also access the standard output and error
via the OUT and ERR, but care needs to be taken that you either save
the values immediately if other commands are being run at the same
time.
$git->branch(sub {
my $out = $git->OUT;
foreach my $line (@$out)
{
...
}
});
If git signals an error condition the condition variable will croak, so
you will need to wrap your call to recv in an eval if you want to
handle it:
$git->branch(sub {
my $out = eval { shift->recv };
if($@)
{
warn "error: $@";
return;
( run in 0.624 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )