App-KGB

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

 * Documentation
   + client/CVS: mention that CVSROOT is a module
   + add HOWTO.release to MANIFEST
 * Internal:
   + Client/Git: rename _process_commit method to _process_changeset to better
     describe what it does
 * Client/Server:
   + add support for using IRC notices
   + add support for disabling color
 * Client:
   + fix --password option definition
   + rework configuration to make priority explicit

1.24 2012-11-22
  * Documentation:
    + Document KGB protocol (currently v4 JSON only).
    + kgb-client.conf(5): add single-line-commit option.
    + Document web-link configuration via git-config.
  * Client:
    + Add a few checks on the configuration file.
    + Add --man and --help command-line options.

eg/kgb-client.conf.sample  view on Meta::CPAN

 - "/(trunk|tags|apps|attic)/([^/]+)"
 - "/branches/([^/]+)/([^/]+)"
# for layout 1 package -> trunk/branches/tags) naturally the package name comes
# into $1 and the branch - into $2. To remedy the situation, use the other
# variant:
# module-and-branch-re:
# - "/packages/([^/]+)/branches/([^/]+)"
# - "/packages/([^/]+)/(?:trunk|tags)/([^/]+)"
#
# some global parameters can be set for all servers
password: "very secret"
timeout: 15
# also, a single server can be defined with 'uri'
# uri: htp://somewhere/
# or, a failover group of servers can be defined
servers:
 - uri: http://localhost:9999/
   timeout: 5 # no point in waiting longer for localhost
 - uri: http://remotehost:9999/
   password: "overrides the global one"
# status-dir is used to store the last successfully contacted server
# this information is used later in order to try to contact the same server
# again (if later contact is within some not very big time frame)
status-dir: /var/cache/kgb/client-status
# a commit URL template to send to the server
# ${module}, ${branch} and ${commit} are replaced with the data from the commit
# Examples:
#  "http://svn.debian.org/viewvc/kgb?view=revision&revision=${commit}"
#  "http://git.debian.org/?p=our-project/${module}.git;a=commitdiff;h=${commit}"
web-link: ~

eg/post-commit  view on Meta::CPAN


REPOS="$1"
REV="$2"

BOT="`dirname "$0"`"/KGB/script/kgb-client
URI="http://localhost:9999/"

REPO_ID="`echo "$REPOS" | sed 's/-/_/g; s#^.*\(/srv/svn.debian.org\|\)/svn/\(.\+\)$#\2#; s#/*$##'`"
PASSWORD="secret"

#"$BOT" --uri "$URI" --repo-id "$REPO_ID" --password "$PASSWORD" "$REPOS" "$REV"
"$BOT" --conf /path/to/client.conf "$REPOS" "$REV"

eg/test-client.conf  view on Meta::CPAN

---
repo-id: test
branch-and-module-re:
 - "/(trunk|tags|apps|attic)/([^/]+)"
 - "/branches/([^/]+)/([^/]+)"
web-link: "http://scm.host.org/${module}/${branch}/?commit=${commit}"
use-irc-notices: 0
use-color: 1
password: "truely secret"
timeout: 15
servers:
 - uri: http://localhost:9998/
 - uri: http://localhost:9997/
# Custom notification formats activate all-in-client function.
# When enabled, all message formatting is done on client side
# and the result is given to the server for relaying on IRC.
#
# The substitutions are in the following format:
#  ${<pre>{<item>}<post>}

eg/test-server-1.conf.d/repos.conf  view on Meta::CPAN

# vim: filetype=yaml
---
repositories:
  # just a name to identify it
  test:
    # needs to be the same on the client
    password: "truely secret"
networks:
  local:
    nick: KGB
    server: localhost
    port: 6667
    use_ssl: 0
    flood: 1
channels:
  - name: '#test'
    network: 'local'

eg/test-server-2.conf  view on Meta::CPAN

# vim: filetype=yaml
---
soap:
  server_addr: 127.0.0.1
  server_port: 9997
  service_name: KGB
repositories:
  # just a name to identify it
  test:
    # needs to be the same on the client
    password: "truely secret"
# Some witty answer for people that talk to the bot
smart_answers:
  - "I won't speak with you!"
  - "Do not disturb!"
  - "Leave me alone, I am buzy!"
smart_answers_polygen: 1
admins:
  - '*!*@localhost'
networks:
  local:

etc/kgb.conf  view on Meta::CPAN

  server_addr: 127.0.0.1
  server_port: 5391
  service_name: KGB
queue_limit: 150
log_file: "/var/log/kgb-bot.log"
include: "/etc/kgb-bot/kgb.conf.d"
repositories:
  # just a name to identify it
  foo:
    # needs to be the same on the client
    password: ~
    # private repositories aren't announced to broadcast channels
    # private: yes
# Some witty answer for people that talk to the bot
#smart_answers:
#  - "I won't speak with you!"
#  - "Do not disturb!"
#  - "Leave me alone, I am buzy!"
# Admins are allowed some special !commands (currently only !version)
#admins:
#  - some!irc@mask
#  - some!other@host
networks:
  freenode:
    nick: KGB
    ircname: KGB bot
    username: kgb
    password: ~
    nickserv_password: ~
    server: irc.freenode.net
channels:
# a broadcast channel
  - name: '#commits'
    network: freenode
    broadcast: yes
# a channel, tied to one or several repositories
#  - name: '#foo'
#    network: freenode
#    repos:

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

=item X-KGB-Auth: hash

=back

The project name is the string identifying the project on the server side, and
the hash is the hexadecimal representation of the SHA-1 hash calculated over
the following data:

=over

=item Project password

This is the shared password known to the client and the server.

=item project-name

=item request-text

This is the JSON-encoded request text. The same that is sent in the HTTP body.

=back

=head2 Commit notification

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

=item B<uri> I<URI>

URI of the KGB server. Something like C<http://some.server:port>. B<Mandatory>
either as a top-level parameter or as a sub-parameter of B<servers> array.

=item B<proxy> I<URI>

URI of the SOAP proxy. If not given, it is the value of the B<uri> option, with
C<?session=KGB> added.

=item B<password> I<password>

Password for authentication to the KGB server. B<Mandatory> either as a
top-level parameter or as a sub-parameter of B<servers> array.

=item B<timeout> I<seconds>

Timeout for server communication. Default is 15 seconds, as we want instant IRC
and commit response.

=item B<servers>

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


=head1 NAME

App::KGB::Client::ServerRef - server instance in KGB client

=head1 SYNOPSIS

    use App::KGB::Client::ServerRef;
    my $s = App::KGB::Client::ServerRef->new(
        {   uri      => "http://some.server:port/",
            password => 's3cr1t',
            timeout  => 5
        }
    );

    $s->send_changes( $client, $protocol_ver, $commit, $branch, $module, { extra => stuff } );

    $s->relay_message( $client, $message, [ { opts } ] );

=head1 DESCRIPTION

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


=item B<uri> (B<mandatory>)

The URI of the remote KGB server. Something like C<http://some.host:port/>.

=item B<proxy>

This is the SOAP proxy used to communicate with the server. If omitted,
defaults to the value of B<uri> field, with C<?session=KGB> appended.

=item B<password> (B<mandatory>)

Password, to be used for authentication to the remote KGB server.

=item B<timeout>

Specifies the timeout for the SOAP transaction in seconds. Defaults to 15
seconds.

=item B<verbose>

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


Helper method sending commit information via JSON-RPC. Dies on errors.

=back

=cut

require v5.10.0;
use base 'Class::Accessor::Fast';

__PACKAGE__->mk_accessors( qw( uri proxy password timeout verbose dry_run ) );

use utf8;
use Carp qw(confess);
use Digest::SHA qw(sha1_hex);
use YAML ();

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

    defined( $self->uri )
        or confess "'uri' is mandatory";
    defined( $self->proxy )
        or $self->proxy( $self->uri . '?session=KGB' );
    defined( $self->password )
        or confess "'password' is mandatory";

    return $self;
}

sub send_changes {
    my ( $self, $client, $protocol_ver, $commit, $branch, $module, $extra )
        = @_;

    # Detect utf8 strings and set the utf8 flag, or try to convert from latin1
    my $repo_id = $client->repo_id;
    my $commit_id = $commit->id;
    my $commit_author = $commit->author;
    my $commit_log = $commit->log;
    my @commit_changes = $commit->changes ? @{ $commit->changes } : ();
    my $password = $self->password;

    my $slc = $client->single_line_commits;
    if ( $slc eq 'forced' ) {
        $commit_log =~ s/\n.*//s;
    }
    elsif ( $slc eq 'auto' ) {
        $commit_log =~ s/^[^\n]+\K\n\n.*//s;
    }

    foreach ( $repo_id, $commit_id, @commit_changes, $commit_log,
        $commit_author, $branch, $module, $password ) {
        next unless ( defined );
        next if ( utf8::is_utf8($_) );
        my $t = $_;
        if ( utf8::decode($t) ) {
            # valid utf8 char seq
            utf8::decode($_);
        } else {
            # try with legacy encoding
            utf8::upgrade($_);
        }

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

            $dump = Data::Dumper::Dump($message);
        }
        else {
            $dump = '(Neither Devel::PartialDump nor Data::Dumper available)';
        }

        confess "Unable to encode message structure as JSON\n" . $dump . "\n"
            . $@;
    }

    my $hash = sha1_hex( $self->password, $repo_id, $json );

    $rpc->ua->default_header( 'X-KGB-Auth', $hash );
    $rpc->ua->default_header( 'X-KGB-Project', $repo_id );

    if ( $self->verbose ) {
        printf "JSON/RPC call: %s/json-rpc\n", $self->uri;
        print "Headers:\n", $rpc->ua->default_headers->as_string;
        print "Message:\n", YAML::Dump($message);
    }
    if ( $self->dry_run ) {

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

    my ( $self, $info ) = @_;

    my $message = join( "",
        $info->{repo_id},
        $info->{commit_id} // (),
        map( "$_", @{ $info->{changes} } ),
        $info->{commit_log},
        $info->{author} // (),
        $info->{branch} // (),
        $info->{module} // (),
        $self->password );
    utf8::encode($message);
    my $checksum = sha1_hex($message);
    # SOAP::Transport::HTTP tries to convert all characters to byte sequences,
    # but fails. See around line 204
    my @message = (
        2,
        (   map {
                SOAP::Data->type(
                    string => Encode::encode( 'UTF-8', $_ ) )
            } ( $info->{repo_id}, $checksum, $info->{rev_prefix}, $info->{commit_id} )

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

    $self->send_changes_soap( \@message );
}

sub send_changes_v3 {
    my ( $self, $info ) = @_;

    my $serialized = Storable::nfreeze($info);

    my @message = (
        3, $info->{repo_id}, $serialized,
        sha1_hex( $info->{repo_id}, $serialized, $self->password )
    );

    $self->send_changes_soap(\@message );
}

sub send_changes_v4 {
    my ( $self, $info ) = @_;

    $self->send_changes_json( $info->{repo_id},
        { method => 'commit_v4', params => [$info] } );

man5/kgb-client.conf.pod  view on Meta::CPAN


The file format is YAML. Elaborate example configuration is at the end of this
document.

=head1 Server connection configuration

=head2 repo-id

Unique project identifier on the server. B<Mandatory>.

=head2 password

Pass phrase string. Used together with B<repo-id> to authenticate the request
to the servers. Per-server configuration overrides this setting.

=head2 timeout

Request timeout in seconds. Defaults to C<15>.

=head2 servers

man5/kgb-client.conf.pod  view on Meta::CPAN


=item B<uri>

The URI of the server. Something like C<http://kgb.server.org:port/>.

=item B<proxy>

SOAP proxy to use. Mandatory if using SOAP protocol. Defaults to to the value
of the B<uri> setting, with C<?session=KGB> appended.

=item B<password>

Per-server pass phrase. Defaults to the global B<password> setting.

=item B<timeout>

Timeout of the request. Defaults to the global B<timeout> setting.

=back

=head2 B<status_dir>

Directory to store information about the last successfully contacted server. If

man5/kgb-client.conf.pod  view on Meta::CPAN


Some of the backends may support additional configuration options. See
L<App::KGB::Client::Git>, L<App::KGB::Client::Subversion> and
L<App::KGB::Client::CVS>.

=head1 EXAMPLE CONFGURATION

 # vim: filetype=yaml
 ---
 repo-id: 'kgb'
 password: 'notknown'
 timeout: 7
 status-dir: '/home/proj/kgb-client/status'
 module-and-branch-re:
  - '^/([^/]+)/(trunk|tags/(?:[^/]+))/'
  - '^/([^/]+)/branches/([^/]+)/'
  - '^/(website)/()'
 web-link: 'http://svn.debian.org/viewvc/${project}?view=revision&revision=${commit}'
 # web-link: 'http://anonscm.debian.org/gitweb/?p=${project}/${module}.git;a=commitdiff;h=${commit}'
 #short-url-service: 'TinyURL'
 short-url-service: 'Debli'
 ignore-branch: 'trunk'
 use-irc-notices: 0
 use-color: 1
 servers:
  - uri: 'http://kgb.server.org:9418/'
  - uri: 'http://another.kgb.server.org:9418/'
    timeout: 3
    password: 'notknowneither'

=head1 SEE ALSO

L<kgb-client(1)>, L<App::KGB::Client>, L<WWW::Shorten>, L<WWW::Shorten::Debli>,
L<kgb-bot(1)>

=head1 AUTHOR

=over

man5/kgb.conf.pod  view on Meta::CPAN

prevent the message to be sent right away. In this case messages are enqueued,
and this parameter configures the size of the queue. When the queue is full
client requests are rejected.

=head2 repositories

A map with keys project names and values maps with project details:

=over

=item password

Password used for authenticating all requests from this project.

=item private

If true, disables commit announces to 'broadcast' IRC channels.

=back

=head2 networks

man5/kgb.conf.pod  view on Meta::CPAN

Bot's nick on the network.

=item ircname

The full name of the bot on the network.

=item username

The username presented to the network.

=item password

A password for the network.

=item nickserv_password

A password for Nick server identification.

=item flood

If defined to a true value, the built-in rate-limitting feature of the IRC
component will be turned off. B<WARNING>: this may cause the bot to be kicked
off the IRC network. Use only when you control both the bot and the IRC network
(e.g. when testing).

=back

man5/kgb.conf.pod  view on Meta::CPAN

   server_addr: 127.0.0.1
   server_port: 9999
   service_name: KGB
 queue_limit: 150
 log_file: "/var/log/kgb-bot.log"
 include: "/etc/kgb-bot/kgb.conf.d"
 repositories:
   # just a name to identify it
   foo:
     # needs to be the same on the client
     password: supersecret
     # private repositories aren't announced to broadcast channels
     # private: yes
 # Some witty answer for people that talk to the bot
 #smart_answers:
 #  - "I won't speak with you!"
 #  - "Do not disturb!"
 #  - "Leave me alone, I am buzy!"
 # Admins are allowed some special !commands (currently only !version)
 #admins:
 #  - some!irc@mask
 #  - some!other@host
 networks:
   freenode:
     nick: KGB
     ircname: KGB bot
     username: kgb
     password: ~
     nickserv_password: ~
     server: irc.freenode.net
     port: 6667
 channels:
 # a broadcast channel
   - name: '#commits'
     network: freenode
     broadcast: yes
 # a channel, tied to one or several repositories
   - name: '#foo'
     network: freenode

script/kgb-add-project  view on Meta::CPAN


my $yaml = LoadFile($file);
my $networks = $yaml->{networks};

if ( $dir and -d $dir ) {
    $yaml = {};
}

my ( $prj, $chan, $pwd ) = @ARGV;

$yaml->{repositories}{$prj}{password} = $pwd;

unless ( $chan =~ /^[#&+]/ ) {
    warn "W: Prepending channel name with a hash sign.\n";
    $chan = "#$chan";
}

unless ( exists $networks->{$net} ) {
    warn "W: Network '$net' missing on configuration file.\n";
}

script/kgb-add-project  view on Meta::CPAN

}

__END__

=head1 NAME

kgb-add-project - helper script for adding new projects to kgb-bot configuration file

=head1 SYNOPSIS

B<kgb-add-project> [--file configfile] [--dir configdir] [--net|--networks ircnetwork] [--save|--write] project-id ircchannel password

=head1 DESCRIPTION

B<kgb-add-project> allows one to add new projects to B<kgb-bot>'s configuration
file from the command line. It writes the new config to stdout unless I<--save|--write> is given.

=head1 ARGUMENTS

=over

script/kgb-add-project  view on Meta::CPAN

=item B<project-id>

B<project-id> to be added.

=item B<irchannel>

IRC channel where the new project sends its messages. If the channel doesn't
start with a character denoting IRC channel (C<#&+>), then a hash sign is
prepended.

=item B<password>

Password for the new project.

=back

=head1 EXAMPLE

B<kgb-add-project> my-project \#projectchannel RudFiarced0

=head1 CAVEATS

script/kgb-bot  view on Meta::CPAN

    }
}

sub do_commit_v0 {
    my ( $kernel, $repo_id, $passwd, $rev, $paths, $log, $author )
        = @_;

    throw Error::Simple("Unknown repository '$repo_id'\n")
        unless $KGB::config->{repositories}{$repo_id};

    throw Error::Simple("Invalid password for repository $repo_id\n")
        if $KGB::config->{repositories}{$repo_id}{password}
        and $KGB::config->{repositories}{$repo_id}{password} ne $passwd;

    do_commit_msg(
        $kernel,
        $repo_id,
        {   rev_prefix => 'r',
            commit_id  => $rev,
            changes    => $paths,
            commit_log => $log,
            author     => $author
        }

script/kgb-bot  view on Meta::CPAN

    utf8::decode($_)
        for ( $repo_id, $rev, @$paths, $log, $author, $branch, $module );
    my $message = join( "",
        $repo_id,
        $rev // (),
        @$paths,
        $log,
        ( defined($author) ? $author : () ),
        ( defined($branch) ? $branch : () ),
        ( defined($module) ? $module : () ),
        $KGB::config->{repositories}{$repo_id}{password} );
    utf8::encode($message);    # Convert to byte-sequence

    throw Error::Simple("Authentication failed for repository $repo_id\n")
        if $KGB::config->{repositories}{$repo_id}{password}
        and sha1_hex($message) ne $checksum;

    do_commit_msg(
        $kernel,
        $repo_id,
        {   rev_prefix => $rev_prefix,
            commit_id  => $rev,
            changes    => $paths,
            commit_log => $log,
            author     => $author,

script/kgb-bot  view on Meta::CPAN

        }
    );
}

sub do_commit_v3 {
    my ( $kernel, $repo_id, $serialized, $checksum ) = @_;

    throw Error::Simple("Repository $repo_id is unknown\n")
        unless exists $KGB::config->{repositories}{$repo_id};

    my $pwd = $KGB::config->{repositories}{$repo_id}{password};
    throw Error::Simple("Authentication failed for repository $repo_id\n")
        if not defined($pwd)
        or sha1_hex( $repo_id, $serialized, $pwd ) ne $checksum;

    my $data;
    my $ok = eval { $data = Storable::thaw($serialized); 1 };

    throw Error::Simple("Invalid serialized data\n")
        unless $ok;

script/kgb-bot  view on Meta::CPAN

    foreach my $net ( keys %current ) {
        next unless ( defined( $current{$net} ) );
        my ( $new, $old )
            = ( $KGB::config->{networks}{$net}, $current{$net} );
        if ( !$new ) {
            push @to_stop, $net;
        }
        elsif ($new->{nick} ne $old->{nick}
            or $new->{ircname}  ne $old->{ircname}
            or $new->{username} ne $old->{username}
            or ( $new->{password} || "" ) ne ( $old->{password} || "" )
            or ( $new->{nickserv_password} || "" ) ne
            ( $old->{nickserv_password} || "" )
            or $new->{server} ne $old->{server}
            or $new->{port}   ne $old->{port}
            or ( $new->{use_ssl} // '' ) ne ( $old->{use_ssl} // '' )
    )
        {
            push @to_restart, $net;
        }
        else {
            my ( %newchan, %oldchan, %allchan );
            %newchan = map( { $_ => 1 } @{ $new->{channels} } );

script/kgb-bot  view on Meta::CPAN


    $irc_object->plugin_add( $KGB::const{AJsvc},
        POE::Component::IRC::Plugin::AutoJoin->new(
            Channels => $opts->{channels},
            NickServ_delay => 60,
        )
    ) if ( $opts->{channels} );

    $irc_object->plugin_add( $KGB::const{NSsvc},
        POE::Component::IRC::Plugin::NickServID->new(
            Password => $opts->{nickserv_password},
        )
    ) if ( $opts->{nickserv_password} );

    $irc_object->plugin_add( $KGB::const{NRsvc},
        POE::Component::IRC::Plugin::NickReclaim->new() );

    $irc_object->plugin_add( $KGB::const{Connsvc},
        POE::Component::IRC::Plugin::Connector->new() );

    $irc_object->plugin_add( $KGB::const{BAsvc},
        POE::Component::IRC::Plugin::BotAddressed->new() );

script/kgb-bot  view on Meta::CPAN

        )
    );

    $kernel->post(
        $sender => connect => {
            Server   => $opts->{server},
            Port     => $opts->{port},
            Nick     => $opts->{nick},
            Ircname  => $opts->{ircname},
            Username => $opts->{username},
            Password => $opts->{password},
            Flood    => $opts->{flood},
            UseSSL   => $opts->{use_ssl},
        }
    );
    undef;
}

sub _default {
    return 0 unless $KGB::debug;
    my ( $event, $args ) = @_[ ARG0 .. $#_ ];

script/kgb-bot  view on Meta::CPAN

            'Invalid or missing X-KGB-Project or X-KGB-Auth headers' );
        $_[KERNEL]->post( $_[SENDER], DONE => $resp );
        return;
    }

    unless ( exists $KGB::config->{repositories}{$repo_id} ) {
        http_error( $resp, "Unknown project ($repo_id)" );
        $_[KERNEL]->post( $_[SENDER], DONE => $resp );
        return;
    }
    my $check = sha1_hex( $KGB::config->{repositories}{$repo_id}{password},
        $repo_id, $req->content );

    unless ( $check eq $auth ) {
        http_error( $resp, "[$repo_id] Authentication failed", 401 );
        $_[KERNEL]->post( $_[SENDER], DONE => $resp );
        return;
    }

    my $json;
    my $ok = eval { $json = decode_json( $req->content ); 1; };

script/kgb-client  view on Meta::CPAN


kgb-client - relay commits to KGB servers

=head1 SYNOPSIS

=over

=item B<kgb-client> --conf I</path/to/config> [I<other-option> ...]

=item B<kgb-client> --uri I<http://some.server:port/service>
                    --password I<password>
                    --repo-id I<repository>
                    --repository I<svn|git|cvs>
                    --timeout I<timeout-in-seconds>
                    --single-line-commits I<off|forced|auto>
                    --use-irc-notices
                    --web-link I<template>
                    --short-url-service I<service>
                    --status-dir I<directory>
                    --[no]-use-color
                    --message-template I<template>

script/kgb-client  view on Meta::CPAN


=item B<--conf> I<configuration file>

Specifies the path to kgb-client configuration file.

=back

Configuration options (except B<--conf>, B<--fake> and B<--relay-msg>) may be
specified both in the configuration file and on the command line. Usually you
want to have all the
options in a configuration file, because having passwords on the command line
is insecure. The configuration file also gives more control, for example it
supports multiple servers and multiple ways of detection of branch and module
names.

See L<kgb-client.conf(5)> for available configuration options. Unless noted
otherwise, all the options in the configuration file can also be used on
command line, prefixing them with two dashes. E.g. C<repo-id> becomes
C<--repo-id>.

Options given on the command line take precedence over configuration file.

script/kgb-client  view on Meta::CPAN


# option settings may come from three sources:
# 1. defaults
# 2. configuration file
# 3. command line
# Sources are evaluated in this order. Every source overrides previous ones

my $debug;

my ($conf_file,      $uri,        $proxy,
    $repo_id,        $password,   $timeout,
    $verbose,        $repo_type,  @br_mod_re, @mod_br_re,
    $br_mod_re_swap, $module,     $ignore_branch,
    @servers,        $git_reflog, $single_line_commits,
    $status_dir,     $web_link,   $short_url_service,
    $fake,           $protocol,   $relay_msg,
    $help,           $man,        $use_irc_notices,
    $use_color,      %colors,     $msg_template,
    $batch_messages, $dry_run,

    # Git

script/kgb-client  view on Meta::CPAN

if( $conf_file ) {
    $conf = YAML::LoadFile($conf_file)
        or die "Error loading config from $conf_file\n";

    if ( ref($conf) ne "HASH" ) {
        die "Invalid configuration: root element must be a map.\n";
    }
    from_conf( uri                         => \$uri );
    from_conf( proxy                       => \$proxy );
    from_conf( 'repo-id'                   => \$repo_id );
    from_conf( password                    => \$password );
    from_conf( timeout                     => \$timeout );
    from_conf( 'branch-and-module-re'      => \@br_mod_re );
    from_conf( 'module-and-branch-re'      => \@mod_br_re );
    from_conf( 'branch-and-module-re-swap' => \$br_mod_re_swap );
    from_conf( 'ignore-branch'             => \$ignore_branch );
    from_conf( module                      => \$module );
    from_conf( repository                  => \$repo_type );
    from_conf( 'single-line-commits'       => \$single_line_commits );
    from_conf( 'use-irc-notices'           => \$use_irc_notices );
    from_conf( 'status-dir'                => \$status_dir );

script/kgb-client  view on Meta::CPAN

    from_conf( 'tag-squash-msg-template' => \$tag_squash_msg_template );
}


Getopt::Long::Configure('no_pass_through');

GetOptions(
    'uri=s'                      => \$uri,
    'proxy=s'                    => \$proxy,
    'repo-id=s'                  => \$repo_id,
    'pass|password=s'            => \$password,
    'timeout=s'                  => \$timeout,
    'branch-and-module-re=s'     => \@br_mod_re,
    'br-mod-re=s'                => \@br_mod_re,
    'module-and-branch-re=s'     => \@mod_br_re,
    'mod-br-re=s'                => \@mod_br_re,
    'branch-and-module-re-swap!' => \$br_mod_re_swap,
    'module=s'                   => \$module,
    'ignore-branch=s'            => \$ignore_branch,
    'repository=s'               => \$repo_type,
    'verbose!'                   => \$verbose,

script/kgb-client  view on Meta::CPAN

    @br_mod_re = ();
}

undef($use_irc_notices)
    if $use_irc_notices and $use_irc_notices =~ /^(?:no|false)$/i;

push @servers, { uri => $uri } if $uri;

@servers = map {
    App::KGB::Client::ServerRef->new(
        {   password => $password,
            timeout  => $timeout,
            verbose  => $verbose,
            dry_run  => $dry_run,
            %$_
        }
        )
} @servers;

die "no servers defined. use 'uri' or 'servers' configuration options\n"
    unless @servers;

t/50-client.t  view on Meta::CPAN

TestBot->expect(
    "dummy/#test 12test/ 3 ${TestBot::COMMIT_USER} 05/file replace file * 14http://scm.host.org///?commit=3"
);

ok( 1, "Test repository prepared" );

use App::KGB::Client::Subversion;
use App::KGB::Client::ServerRef;

my $port = 7645;
my $password = 'v,sjflir';

my $c = new_ok(
    'App::KGB::Client::Subversion' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:$port/",
                        password => $password,
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            repo_path => $repo,
            revision  => 1,
        }

t/51-client_branch_module.t  view on Meta::CPAN

        or plan skip_all => "SVN::Fs required for testing the Subversion client";
    eval { require SVN::Repos; 1 }
        or plan skip_all => "SVN::Repos required for testing the Subversion client";
};

use App::KGB::Change;
use App::KGB::Client::Subversion;
use App::KGB::Client::ServerRef;

my $port = 7645;
my $password = 'v,sjflir';

my $c = new_ok(
    'App::KGB::Client::Subversion' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:$port/",
                        password => $password,
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            repo_path => '/',
            revision  => 1,
        }

t/52-client-git.t  view on Meta::CPAN

$ign = $git->command( 'config', 'user.email', 'ser@example.neverland' );

write_tmp 'reflog', '';

my $c = new_ok(
    'App::KGB::Client::Git' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:1234/",
                        password => "hidden",               # not used by this client instance
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            git_dir => $remote,
            reflog  => "$dir/reflog",
        }

t/53-client-git-merges.t  view on Meta::CPAN

$ign = $git->command( 'config', 'user.email', 'ser@example.neverland' );

write_tmp 'reflog', '';

my $c = new_ok(
    'App::KGB::Client::Git' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:1234/",
                        password => "hidden",               # not used by this client instance
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            git_dir => $remote,
            reflog  => "$dir/reflog",
        }

t/54-client-git-squash.t  view on Meta::CPAN

$git->command( 'config', 'user.email', 'ser@example.neverland' );

write_tmp 'reflog', '';

my $c = new_ok(
    'App::KGB::Client::Git' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:1234/",
                        password => "hidden",               # not used by this client instance
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            git_dir => $remote,
            reflog  => "$dir/reflog",
        }

t/55-client-git-merges-ff.t  view on Meta::CPAN

$git->command( 'config', 'user.email', 'ser@example.neverland' );

write_tmp 'reflog', '';

my $c = new_ok(
    'App::KGB::Client::Git' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:1234/",
                        password => "hidden",               # not used by this client instance
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            git_dir => $remote,
            reflog  => "$dir/reflog",
        }

t/56-client-git-ff-merge-2.t  view on Meta::CPAN

$git->command( 'config', 'user.email', 'ser@example.neverland' );

write_tmp 'reflog', '';

my $c = new_ok(
    'App::KGB::Client::Git' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:1234/",
                        password => "hidden",               # not used by this client instance
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            git_dir => $remote,
            reflog  => "$dir/reflog",
        }

t/57-client-git-squash-tags.t  view on Meta::CPAN

$git->command( 'config', 'user.email', 'ser@example.neverland' );

write_tmp 'reflog', '';

my $c = new_ok(
    'App::KGB::Client::Git' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:1234/",
                        password => "hidden",               # not used by this client instance
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            git_dir => $remote,
            reflog  => "$dir/reflog",
        }

t/58-client-git-unicode.t  view on Meta::CPAN

$ign = $git->command( 'config', 'user.email', 'ser@example.neverland' );

write_tmp 'reflog', '';

my $c = new_ok(
    'App::KGB::Client::Git' => [
        {   repo_id => 'test',
            servers => [
                App::KGB::Client::ServerRef->new(
                    {   uri      => "http://127.0.0.1:1234/",
                        password => "hidden",               # not used by this client instance
                    }
                ),
            ],

            #br_mod_re      => \@br_mod_re,
            #br_mod_re_swap => $br_mod_re_swap,
            #ignore_branch  => $ignore_branch,
            git_dir => $remote,
            reflog  => "$dir/reflog",
        }

t/TestBot.pm  view on Meta::CPAN

    print $fh <<EOF;
---
soap:
  server_addr: $addr
  server_port: $port
  service_name: KGB
pid_dir: t/bot
debug: 0
repositories:
 test:
   password: "truely secret"
networks:
 dummy:
  nick: KGBOO
  server: nonexisting
channels:
 - name: '#test'
   network: dummy
   repos:
    - test
log_file: $dir/kgb-bot.log

t/TestBot.pm  view on Meta::CPAN

    open( $fh, '>', $client_config_file );
    print $fh <<EOF;
---
repo-id: test
branch-and-module-re:
 - "/(trunk|tags|apps|attic)/([^/]+)"
 - "/branches/([^/]+)/([^/]+)"
web-link: "http://scm.host.org/\${module}/\${branch}/?commit=\${commit}"
use-irc-notices: 0
use-color: 1
password: "truely secret"
timeout: 15
servers:
 - uri: http://$addr:$port/
message-template: "\${{project}/}\${{module}}\${ {branch}}\${ {commit}}\${ {author-name}}\${ ({author-login})}\${ {changes}}\${ {log-first-line}}\${ * {web-link}}"
status-dir: $dir
batch-messages: 1
EOF

    close $fh;



( run in 1.119 second using v1.01-cache-2.11-cpan-49f99fa48dc )