NAME
Git::Repository::Plugin::AUTOLOAD - Git subcommands as Git::Repository methods
VERSION
version 1.001
SYNOPSIS
use Git::Repository 'AUTOLOAD';
my $r = Git::Repository->new();
$r->add($file);
$r->commit( '-m' => 'message' );
# NOTE: might be overridden by the 'Log' plugin
my $log = $r->log('-1');
# use "_" for "-" in command names
my $sha1 = $r->rev_parse('master');
# can be used as a class method
Git::Repository->clone( $url );
DESCRIPTION
This module adds an AUTOLOAD
method to Git::Repository, enabling it to automagically call git commands as methods on Git::Repository objects.
METHODS
AUTOLOAD
Any method call caught by AUTOLOAD
will simply turn all _
(underscore) into -
(dash), and call run()
on the invocant, with the transformed method name as the first parameter.
For example:
my $sha1 = $r->rev_parse('master');
does exactly the same thing as:
my $sha1 = $r->run( 'rev-parse', 'master' );
All parameters to the original method call are kept, so these autoloaded methods can take option hashes.
Note that AUTOLOAD
does not install methods in the invocant class (but what's the cost of a Perl subroutine call compared to forking a git subprocess?), so that plugins adding new methods always take precedence.
SEE ALSO
Git::Repository, Git::Repository::Plugin.
BUGS
Please report any bugs or feature requests on the bugtracker website http://rt.cpan.org/NoAuth/Bugs.html?Dist=Git-Repository-Plugin-AUTOLOAD or by email to bug-git-repository-plugin-autoload@rt.cpan.org.
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHOR
Philippe Bruhat (BooK) <book@cpan.org>
COPYRIGHT
Copyright 2014 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.