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
93
94
95
96
97
98
99
100
|
use strict; use warnings;
use YAML::Tiny;
my @docs;
{ open my $ef, '<:utf8', '_data/scripts.yaml' or die $!;
@docs = Load(do { local $/; <$ef> });
}
my %oldmeta;
for (@{$docs[0]//[]}) {
$oldmeta{$_->{filename}} = $_;
}
my %newmeta;
for my $file (<scripts/*.pl>) {
my ($filename, $base) =
$file =~ m,^scripts/((.*)\.pl)$,;
my $info_file = "Test/$base/info.yml";
my @cdoc;
if (-f $info_file && open my $ef, '<:utf8', $info_file) {
local $@;
@cdoc = eval { Load(do { local $/; <$ef> }); };
if ($@) {
print "ERROR $base: $@\n";
@cdoc=();
}
}
if (@cdoc) {
$newmeta{$filename} = $cdoc[0][0];
for my $copykey (qw(modified version)) {
unless (defined $newmeta{$filename}{$copykey}) {
$newmeta{$filename}{$copykey}
= $oldmeta{$filename}{$copykey}
if defined $oldmeta{$filename}{$copykey};
}
}
$newmeta{$filename}{filename} = $filename;
my $modules = delete $newmeta{$filename}{modules};
$newmeta{$filename}{modules}
= join ' ', @$modules
if 'ARRAY' eq ref $modules;
}
elsif (exists $oldmeta{$filename}) {
print "META-INF FOR $base NOT FOUND\n";
system "ls 'Test/$base/'*";
$newmeta{$filename} = $oldmeta{$filename};
}
else {
print "MISSING META FOR $base\n";
}
}
my @newdoc = map { $newmeta{$_} } sort keys %newmeta;
{ open my $ef, '>:utf8', '_data/scripts.yaml' or die $!;
print $ef Dump \@newdoc;
}
my @config;
if (open my $ef, '<:utf8', '_testing/config.yml') {
@config = Load(do { local $/; <$ef> });
}
if (@config && @{$config[0]{whitelist}//[]}) {
my $changed;
my @wl;
for my $sf (@{$config[0]{whitelist}}) {
if (-s "Test/$sf:passed") {
$changed = 1;
}
else {
push @wl, $sf;
}
}
if ($changed) {
$config[0]{whitelist} = \@wl;
{ open my $ef, '>:utf8', '_testing/config.yml' or die $!;
print $ef Dump @config;
}
}
}
if (exists $ENV{REPO_LOGIN_TOKEN} && exists $ENV{TRAVIS_REPO_SLUG}) {
{ open my $cred, '>', "$ENV{HOME}/.git-credentials" or die $!;
print $cred "https://$ENV{REPO_LOGIN_TOKEN}:x-oauth-basic\@github.com\n";
}
system qq[
git config user.email "scripts\@irssi.org"
git config user.name "Irssi Scripts Helper"
git config credential.helper store
git config remote.origin.url https://github.com/$ENV{TRAVIS_REPO_SLUG}
git checkout '$ENV{TRAVIS_BRANCH}'
if [ "\$(git log -1 --format=%an)" != "\$(git config user.name)" -a \\
"\$(git log -1 --format=%cn)" != "\$(git config user.name)" ]; then
git add _data/scripts.yaml
git commit -m 'automatic scripts database update for $ENV{TRAVIS_COMMIT}
[skip ci]'
git config push.default simple
git push origin
fi
];
}
|