App-GitWorkspaceScanner
view release on metacpan or search on metacpan
lib/App/GitWorkspaceScanner.pm view on Meta::CPAN
Set whether untracked files should generate a warning in the report. Currently
on by default, but this is likely to change in the near future as we add/clean
up our .gitignore files.
# Do not warn on untracked files (default).
./scan_git_repositories --allow_untracked_files=0
# Warn on untracked files.
./scan_git_repositories --allow_untracked_files=1
=item * C<--allowed_branches>
Generate a warning if the current branch doesn't match one of the branches
specified. Set to C<master> default.
# Allow only using the master branch.
./scan_git_repositories
# Allow only using the master branch.
./scan_git_repositories --allowed_branches=master
# Allow only using the master and production branches.
./scan_git_repositories --allowed_branches=master,production
=item * C<--allow_any_branches>
Disable the check performed by C<--allowed_branches>, which is set to force
using the C<master> branch by default.
# Don't check the branch the repository is on.
./scan_git_repositories --allow_any_branches=1
=item * C<--whitelist_repositories>
Excludes specific repositories from the checks performed by this script. The
argument accepts a comma-separated list of paths to ignore, but by default no
repositories are whitelisted.
# Whitelist /root/my_custom_repo
./scan_git_repositories --whitelist_repositories=/root/my_custom_repo
=back
=head1 CAVEATS
=over 4
=item *
This script currently uses C<locate> to scan the current machine for git
repositories, so this only works for Linux/Unix machines.
=item *
If you are not using C<--workspace> to limit the scan to files on which you
have read permissions, this script needs to be run as root.
=item *
You should have C<updatedb> in your crontab running daily, to ensure that new
repositories are picked up.
=item *
You should run this script using C<nice>. While it uses C<locate>, it still has
an impact on the file cache and using C<nice> will help mitigate any potential
issues.
=back
=cut
Readonly::Scalar my $FILE_STATUS_PARSER =>
{
'??' => 'untracked',
'A' => 'added',
'D' => 'deleted',
'M' => 'modified',
'R' => 'moved',
};
=head1 FUNCTIONS
=head2 new()
Create a new C<Git::WorkspaceScanner> object.
my $scanner = Git::WorkspaceScanner->new(
arguments => \@arguments,
);
Arguments:
=over 4
=item * arguments I<(mandatory)>
An arrayref of arguments passed originally to the command line utility.
=back
=cut
sub new
{
my ( $class, %args ) = @_;
# Verify arguments.
my $arguments = delete( $args{'arguments'} );
croak 'The following argument(s) are not valid: ' . join( ', ', keys %args )
if scalar( keys %args ) != 0;
# Create the object.
my $self = bless( {}, $class );
# Parse the arguments provided.
$self->parse_arguments( $arguments );
# If --help was passed, print out usage info and exit.
( run in 1.465 second using v1.01-cache-2.11-cpan-13bb782fe5a )