App-GitHooks
view release on metacpan or search on metacpan
lib/App/GitHooks/Utils.pm view on Meta::CPAN
package App::GitHooks::Utils;
use strict;
use warnings;
# External dependencies.
use Carp;
use File::Spec;
use Try::Tiny;
# No internal dependencies - keep this as a leaf module in the graph so that we
# can include it everywhere.
=head1 NAME
App::GitHooks::Utils - Support functions for App::GitHooks and its plugins.
=head1 VERSION
Version 1.9.0
=cut
our $VERSION = '1.9.0';
=head1 FUNCTIONS
=head2 get_project_prefixes()
Get an arrayref of valid project prefixes.
my $project_prefixes = App::GitHooks::Utils::get_project_prefixes( $app );
Arguments:
=over 4
=item * $app
An C<App::GitHooks> instance.
=back
=cut
sub get_project_prefixes
{
my ( $app ) = @_;
my $config_line = $app->get_config()->{'_'}->{'project_prefixes'} // '';
# Strip leading/trailing whitespace.
$config_line =~ s/(?:^\s+|\s+$)//g;
return [ split( /\s*[, ]\s*/, $config_line ) ];
}
=head2 get_project_prefix_regex()
Return a non-capturing regex that will match all the valid project prefixes.
my $project_prefix_regex = App::GitHooks::Utils::get_project_prefix_regex( $app );
Arguments:
=over 4
( run in 2.699 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )