App-KGB

 view release on metacpan or  search on metacpan

lib/App/KGB/Client/Git.pm  view on Meta::CPAN

file and these given on the command line.

=over

=item project-id

The project ID.

See L<App::KGB::Client/project-id> for details.

=item web-link

See L<App::KGB::Client/web-link> for details.

=item squash-threshold I<number>

Unique to Git KGB client. Sets a threshold of the notifications produced for a
given branch update. If there are more commits in the update, instead of
producing huge amounts of notifications, the commits are "squashed" into one
notification per branch with a summary of the changes.

The default value is C<20>.

=item squash-message-template I<string>

A template for construction of squashed messages. See
L<App::KGB::Client/message-template> for details.

The default is C<${{module} }${{branch} }${{commit} }${{author-name} }${{log}}>.

=item tag-squash-threshold I<number>

Unique to Git KGB client. Sets a threshold of the notifications produced
for tag creations. If there are more tags created in the push, instead
of producing huge amounts of notifications, the tags are "squashed" into
one notification summarizing the information.

The default value is C<5>.

=item tag-squash-message-template I<string>

A template for construction of squashed tags messages. See
L<App::KGB::Client/message-template> for details.

The default is C<${{module} }${{author-name} }${{log}}>.

=item enable-branch-ff-notification I<bool>

Enables notifications about branch updates whose commits have already been
reported. Normally this causes a notification like C<fast forward> to appear.
If you don't like this, set it to false.

The default is C<true>.

=back

=cut

sub new {
    my $class = shift;
    my $self  = $class->SUPER::new(@_);

    $self->git_dir( $ENV{GIT_DIR} )
        unless defined( $self->git_dir );

    defined( $self->git_dir )
        or confess
        "'git_dir' is mandatory; either supply it or define GIT_DIR in the environment";


    $self->_git(
        Git->repository( Repository => encode_utf8( $self->git_dir ) ) );

    unless ( $self->module ) {
        require Cwd;
        my @dirs = File::Spec->splitdir( Cwd::abs_path( $self->git_dir ) );
        pop @dirs if @dirs and $dirs[-1] eq '.git';
        my $module = $dirs[-1];
        $module =~ s/\.git$// if $module;
        $module =
            eval { decode_utf8( $module, FB_CROAK | LEAVE_SRC ) } // $module;
        $self->module($module);
    }

    if ( my $pid = $self->_git->config('kgb.project-id') ) {
        $self->repo_id($pid);
    }
    if ( my $wl = $self->_git->config('kgb.web-link') ) {
        $self->web_link($wl);
    }
    if ( my $st = $self->_git->config('kgb.squash-threshold') ) {
        $self->squash_threshold($st);
    }
    $self->squash_threshold(20) unless defined $self->squash_threshold;
    if ( my $tst = $self->_git->config('kgb.tag-squash-threshold') ) {
        $self->tag_squash_threshold($tst);
    }
    $self->tag_squash_threshold(5)
        unless defined $self->tag_squash_threshold;

    if ( my $smt = $self->_git->config('kgb.squash-message-template') ) {
        $self->squash_msg_template($smt);
    }
    $self->squash_msg_template('${{module} }${{branch} }${{commit} }${{author-name} }${{log}}')
        unless $self->squash_msg_template;
    if ( my $tsmt = $self->_git->config('kgb.tag-squash-message-template') ) {
        $self->tag_squash_msg_template($tsmt);
    }
    $self->tag_squash_msg_template(
        '${{module} }${{author-name}}${ {log}}'
    ) unless $self->tag_squash_msg_template;
    $self->branch_ff_msg_template('${{module} }${{branch} }${{commit} }${{author-name}} fast-forward')
        unless $self->branch_ff_msg_template;

    my $ebfn = $self->_git->config('kgb.enable-branch-ff-notification');
    if ( defined($ebfn) and $ebfn ne '' ) {
        $ebfn = ( $ebfn eq 'false' ) ? 0 : 1;
        $self->enable_branch_ff_notification($ebfn);
    }
    $self->enable_branch_ff_notification(1)
        unless defined $self->enable_branch_ff_notification;



( run in 3.103 seconds using v1.01-cache-2.11-cpan-b9db842bd85 )