~ubuntu-branches/ubuntu/raring/kgb-bot/raring-proposed

« back to all changes in this revision

Viewing changes to script/kgb-bot

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2010-04-28 23:40:15 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100428234015-k86juhxx72aj091v
Tags: 1.03-1
* New upstream release
  + adds rotocol v2 with the ability to explicitly specify revision prefix,
    which is 'r' for Subversion and empty otherwise
* Standardss-Version: 3.8.4 (no changes necessary)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#
6
6
# KGB - an IRC bot helping collaboration
7
7
# Copyright © 2008 Martín Ferrari
8
 
# Copyright © 2008,2009 Damyan Ivanov
 
8
# Copyright © 2008,2009,2010 Damyan Ivanov
9
9
#
10
10
# This program is free software; you can redistribute it and/or modify it under
11
11
# the terms of the GNU General Public License as published by the Free Software
53
53
use encoding 'utf8';
54
54
use open ':encoding(utf8)';
55
55
 
56
 
our $VERSION = '1.01';
 
56
our $VERSION = '1.03';
57
57
 
58
58
use Cwd;
59
59
 
69
69
our %supported_protos = (
70
70
    "0" => 1,
71
71
    "1" => 1,
 
72
    "2" => 1,
72
73
);
73
74
our $progname;
74
75
our $restart      = 0;
484
485
}
485
486
 
486
487
sub do_commit_msg {
487
 
    my ($kernel, $response, $repo_id, $rev, $changes,
488
 
        $log,    $author,   $branch,  $module
 
488
    my ($kernel,  $response, $repo_id, $rev_prefix, $rev,
 
489
        $changes, $log,      $author,  $branch,     $module
489
490
    ) = @_;
490
491
    my @log = split( /\n+/, $log );
491
492
    my $path_string;
527
528
    $path_string = colorize( module => $module ) . " $path_string"
528
529
        if defined($module);
529
530
    my @string
530
 
        = "$repo_head $author_string * r"
 
531
        = "$repo_head $author_string * $rev_prefix"
531
532
        . colorize( revision => $rev )
532
533
        . " $path_string";
533
534
    push @string, "$repo_head $_" for @log;
586
587
        warn("Invalid password\n");
587
588
        return;
588
589
    }
589
 
    do_commit_msg( $kernel, $response, $repo_id, $rev, $paths, $log,
 
590
    do_commit_msg( $kernel, $response, $repo_id, 'r', $rev, $paths, $log,
590
591
        $author );
591
592
}
592
593
 
594
595
    my ($kernel, $response, $repo_id, $checksum, $rev,
595
596
        $paths,  $log,      $author,  $branch,   $module
596
597
    ) = @_;
 
598
 
 
599
    # v1 is the same as v2, but has no rev_prefix parameter
 
600
    return do_commit_v2(
 
601
        $kernel, $response, $repo_id, $checksum, 'r', $rev,
 
602
        $paths,  $log,      $author,  $branch,   $module
 
603
    );
 
604
}
 
605
 
 
606
sub do_commit_v2 {
 
607
    my ($kernel,     $response, $repo_id, $checksum,
 
608
        $rev_prefix, $rev,      $paths,   $log,
 
609
        $author,     $branch,   $module
 
610
    ) = @_;
597
611
    unless ( $KGB::config->{repositories}{$repo_id} ) {
598
612
        $kernel->post(
599
613
            SOAPServer => 'FAULT',
625
639
        return;
626
640
    }
627
641
    do_commit_msg(
628
 
        $kernel, $response, $repo_id, $rev, $paths,
629
 
        $log,    $author,   $branch,  $module
 
642
        $kernel, $response, $repo_id, $rev_prefix, $rev,
 
643
        $paths,  $log,      $author,  $branch,     $module
630
644
    );
631
645
}
632
646
 
689
703
    if ( $proto_ver == 1 ) {
690
704
        return do_commit_v1( $kernel, $response, @{ $params->{Array} } );
691
705
    }
 
706
    if ( $proto_ver == 2 ) {
 
707
        return do_commit_v2( $kernel, $response, @{ $params->{Array} } );
 
708
    }
692
709
    $kernel->post(
693
710
        SOAPServer => 'FAULT',
694
711
        $response, 'Client.Arguments',