NAME
Git::Repository::Plugin::Dirty - methods to inspect the dirtiness of a git repository
VERSION
This document describes Git::Repository::Plugin::Dirty version 0.01
SYNOPSIS
use Git::Repository qw(Dirty);
my $git = Git::Repository->new( { fatal => ["!0"], quiet => ( $verbose ? 0 : 1 ), } );
if ($git->is_dirty) {
if ($force) {
…
}
else {
die "Repo is dirty. Please commit or stash any staged or unstaged changes and try again.\n";
}
}
DESCRIPTION
INTERFACE
$git->is_dirty()
Returns true if there are staged or unstaged changes.
$git->is_dirty(untracked => 1)
Also return true if there are untracked files.
$git->has_unstaged_changes()
Returns true if there are unstaged changes.
$git->has_staged_changes()
Returns true if there are staged changes.
$git->has_untracked()
Returns a list of untracked files.
$git->diff_unstaged()
Returns an array of lines making up the diff of unstaged changes.
$git->diff_unstaged(\&output_handler)
For each line of the unstaged changes diff this handler is called.
It is passed the git object and the line.
Returning true will continue to the next line.
Returning false will stop the command.
$git->diff_staged(sub {
my ($git,$line) = @_;
if ($line =~ m/API_KEY:(.*)/) {
my $api_key = $1;
update_api_key_on_ci_boxes($api_key);
return; # since we found what we where looking for we can stop
}
return 1; # keep going
});
$git->diff_staged()
Returns an array of lines making up the diff of unstaged changes.
$git->diff_staged(\&output_handler)
Same as diff_staged()
but for staged changes.
$git->current_branch()
Returns the current branch. Useful for determining why a repo is dirty and what to do about it.
DIAGNOSTICS
Throws no warnings or errors of its own. Any errors will be from the Git::Repository objects.
CONFIGURATION AND ENVIRONMENT
Git::Repository::Plugin::Dirty requires no configuration files or environment variables.
DEPENDENCIES
INCOMPATIBILITIES AND LIMITATIONS
None reported.
BUGS AND FEATURES
Please report any bugs or feature requests (and a pull request for bonus points) through the issue tracker at https://github.com/drmuey/p5-Git-Repository-Plugin-Dirty/issues.
AUTHOR
Daniel Muey <http://drmuey.com/cpan_contact.pl>
LICENCE AND COPYRIGHT
Copyright (c) 2018, Daniel Muey <http://drmuey.com/cpan_contact.pl>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.