-
Notifications
You must be signed in to change notification settings - Fork 14
/
bot.pl
executable file
·92 lines (82 loc) · 2.94 KB
/
bot.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env perl
# Copyright © 2016
# Aleks-Daniel Jakimenko-Aleksejev <alex.jakimenko@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use v5.10;
use strict;
use warnings;
use utf8;
package Bisectable;
use base 'Bot::BasicBot';
use File::Temp qw( tempfile tempdir );
use Cwd qw(cwd abs_path);
use IO::Handle;
my $link = 'https://github.com/rakudo/rakudo/commit';
my $rakudo = './rakudo';
my $builds = abs_path './builds';
my $commit_tester = abs_path './test-commit';
sub said {
my ($self, $message) = @_;
if ($message->{body} =~ /^bisect:
(?:
(?: \s+ good (?: \s+ | \s*=\s*) ([\w\d.-]+) )
(?: \s+ bad (?: \s+ | \s*=\s*) ([\w\d.-]+) )?
|
(?: \s+ bad (?: \s+ | \s*=\s*) ([\w\d.-]+) )?
(?: \s+ good (?: \s+ | \s*=\s*) ([\w\d.-]+) )?
)
(*PRUNE)
\s+ (.+)
/xu) {
if (defined $message->{address}) {
return 'Sorry, it is too private here';
}
my $good = $1 // $4 // 'v6.c';
my $bad = $2 // $3 // 'HEAD';
my $code = $5;
my ($fh, $filename) = tempfile(UNLINK => 1);
binmode $fh, ':encoding(UTF-8)';
print $fh $code;
close $fh;
my $dir = tempdir(CLEANUP => 1);
# TODO use --no-checkout ?
system('git', 'clone', $rakudo, $dir);
my $oldDir = cwd;
chdir($dir);
system('git', 'bisect', 'start');
system('git', 'bisect', 'good', $good);
system('git', 'bisect', 'bad', $bad);
system('git', 'bisect', 'run', $commit_tester, $builds, $filename);
my $result = `git show --quiet --date=short --pretty='(%cd) $link/%h' bisect/bad`;
chdir($oldDir);
return "$message->{who}: $result";
}
if ($message->{body} eq 'source') {
return 'https://github.com/perl6/bisectbot';
}
}
sub help {
'Like this: bisect: good=v6.c bad=HEAD exit 1 if (^∞).grep({ last })[5] // 0 == 4 # RT 128181'
}
Bisectable->new(
server => 'irc.freenode.org',
port => '6667',
channels => ['#perl6', '#perl6-dev'],
nick => 'bisectable',
alt_nicks => ['bisectable2', 'bisectable3'],
username => 'Bisectable',
name => 'Quick git bisect for Rakudo',
ignore_list => [],
)->run();