generate-changelog.pl 1.3 KB
Newer Older
1 2 3
#!/usr/bin/perl
#
# To use it, just insert your OW2 token in ~/.ow2-token
Xavier Guimard's avatar
Xavier Guimard committed
4 5 6 7
#
# This script downloads issues from gitlab.ow2.org and insert issues title in
# "changelog" file in a new version entry, grouped using tags: Bug,
# New feature, Improvement.
8 9 10
#
# Copyright: Xavier Guimard <x.guimard@free.fr>
# See COPYING for license
11 12 13 14

use LWP::UserAgent;
use JSON;

Xavier Guimard's avatar
Xavier Guimard committed
15
my $milestone = '2.0.2';
Xavier Guimard's avatar
Xavier Guimard committed
16
my @cat = ( 'Bug', 'New feature', 'Improvement' );
17

Xavier Guimard's avatar
Xavier Guimard committed
18
open F, "$ENV{HOME}/.ow2-token" or die "Unable to get OW2 token ($!)";
Xavier Guimard's avatar
Xavier Guimard committed
19
my $token = join '', <F>;
20 21 22 23 24
close F;
$token =~ s/\s//sg or die "No token";

my $ua = LWP::UserAgent->new();

Xavier Guimard's avatar
Xavier Guimard committed
25 26
my $result = '';

27 28
for (@cat) {
    my $res = $ua->get(
Xavier Guimard's avatar
Xavier Guimard committed
29
"https://gitlab.ow2.org/api/v4/projects/181/issues?labels=$_&milestone=$milestone&state=all&scope=all&per_page=100&private_token=$token"
30
    );
Xavier Guimard's avatar
Xavier Guimard committed
31
    $result .= "  * ${_}s:\n";
32
    $res = JSON::from_json( $res->content );
Xavier Guimard's avatar
Xavier Guimard committed
33 34
    while ( my $i = pop @$res ) {
        $result .=  "    * #$i->{iid}: $i->{title}\n";
35
    }
Xavier Guimard's avatar
Xavier Guimard committed
36
    $result .=  "\n";
37
}
Xavier Guimard's avatar
Xavier Guimard committed
38 39 40 41 42 43 44 45 46 47 48 49 50

`dch -c changelog -v $milestone '##CONTENT##';dch -c changelog -r --force-save-on-release '';cp changelog tmp.dch`;
open IN, 'tmp.dch';
open OUT, '>changelog';

$result =~ s/\n\n$//s;
while(<IN>) {
    chomp;
    s/.*##CONTENT##$/$result/;
    print OUT "$_\n";
}

unlink 'tmp.dch';
Xavier Guimard's avatar
Xavier Guimard committed
51 52

print STDERR "./changelog updated\n";