App-KGB

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  * Server:
    + add --debug command line switch
    + replace --config-dir option with 'include:' configuration item
      add 'include: "/etc/kgb-bot/kgb.conf.d"' to the default config
    + default pid_dir to /var/run/kgb-bot
  * Documentation:
    + add manuals for kgb.conf and kgb-client.conf
    + pod.t: test documentation in man*/ too
    + give example for gitweb URL
  * Client:
    + show expanded web-link in verbose mode
    + dump processed configuration in verbose mode
    + shorten_url: really return plain URL if shortening is not enabled
    + send_changes: detailed dump in verbose mode
    + introduce module-and-branch-re setting and deprecate
      branch-and-module-re-swap

1.22 2012-10-14
  * kgb-add-project: document the new --dir option
  * Add API documentation (JSON-RPC only)
  * Server:

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

Print diagnostic information.

=item B<protocol> I<version>

Use specified protocol version. If C<auto> (the default), the version of the
protocol C<2>, unless B<web_link> is also given, in which case protocol version
C<3> is default;

=item B<web_link> I<template>

A web link template to be sent to the server. The following items are expanded:

=over

=item ${branch}

=item ${module}

=item ${commit}

=item ${project}

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

        }
        else {
            warn "Unable to read directory ".$self->status_dir."\n";
            $self->status_dir(undef);
        }
    }

    return @servers;
}

=item expand_link ($string, \%data)

Expands items in the form I<${item}> in I<$string>, using the data in the
supplied hash reference.

Passing

 "http://git/${module}.git?commit=${commit}",
 { module => 'dh-make-perl', commit => '225ceca' }

would result in C<http://git/dh-make-perl.git?commit=225ceca>.

=cut

sub expand_link {
    my ( $self, $input, $data ) = @_;

    my $output = '';
    my $re = qr/\$\{([^{}]+)\}/p;

    while ( $input =~ $re ) {
        my $f = $1;
        my $v;
        if ( exists $data->{$f} ) {
            $v = $data->{$f} // '';
        }
        else {
            $v = '';
            warn "Unknown substitution '$f'\n";
        }

        $output .= ${^PREMATCH} . $v;
        $input = ${^POSTMATCH};
    }

    warn "Web link expanded to $output\n" if $self->verbose;

    return $output;
}

=item shorten_url (url)

Uses the configured I<short_url_service> to shorten the given URL. If no
shortening service is configured, the original URL is returned.

=cut

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

    if ( not defined($module) or not defined($branch) ) {
        my ( $det_branch, $det_module )
            = $self->detect_branch_and_module( $commit->changes );

        $branch //= $det_branch;
        $module //= $det_module;
    }

    my $web_link = $self->web_link;
    if ( defined($web_link) ) {
        $web_link = $self->expand_link(
            $web_link,
            {   branch  => $branch,
                module  => $module,
                commit  => $commit->id,
                project => $self->repo_id
            }
        );
        $web_link = $self->shorten_url($web_link);
    }



( run in 0.962 second using v1.01-cache-2.11-cpan-97f6503c9c8 )