Changed dev-tools/es_release_notes to:

* remove markdown support
* prefer PRs over issues
* include related issues in the list
* always use section headers if there is a header
This commit is contained in:
Clinton Gormley 2014-09-11 16:46:26 +02:00
parent 269b91c688
commit 1455988d91
1 changed files with 39 additions and 27 deletions

View File

@ -24,7 +24,7 @@ use utf8;
my $Base_URL = 'https://api.github.com/repos/';
my $User_Repo = 'elasticsearch/elasticsearch/';
my $Issue_URL = "http://github.com/${User_Repo}issues/issue/";
my $Issue_URL = "http://github.com/${User_Repo}issues/";
my @Groups = qw(breaking feature enhancement bug regression doc test);
my %Group_Labels = (
@ -51,8 +51,6 @@ my $version = shift @ARGV
dump_labels("Unknown version '$version'")
unless $All_Labels{$version};
my $format = shift @ARGV || "html";
my $issues = fetch_issues($version);
dump_issues( $version, $issues );
@ -69,45 +67,48 @@ sub dump_issues {
for my $group ( @Groups, 'other' ) {
my $group_issues = $issues->{$group} or next;
$format eq 'html' and print "<h2>$Group_Labels{$group}</h2>\n\n<ul>\n";
$format eq 'markdown' and print "## $Group_Labels{$group}\n\n";
print "<h2>$Group_Labels{$group}</h2>\n\n<ul>\n";
for my $header ( sort keys %$group_issues ) {
my $header_issues = $group_issues->{$header};
my $prefix = "<li>";
if ($format eq 'html') {
if ( $header && @$header_issues > 1 ) {
print "<li>$header:<ul>";
$prefix = "<li>";
}
elsif ($header) {
$prefix = "<li>$header: ";
}
if ($header) {
print "<li>$header:<ul>";
}
for my $issue (@$header_issues) {
my $title = $issue->{title};
$title=~s{`([^`]+)`}{<code>$1</code>}g
if $format eq 'html';
$title =~ s{`([^`]+)`}{<code>$1</code>}g;
if ( $issue->{state} eq 'open' ) {
$title .= " [OPEN]";
}
unless ( $issue->{pull_request} ) {
$title .= " [ISSUE]";
}
my $number = $issue->{number};
$format eq 'markdown' and print encode_utf8( "* "
print encode_utf8( $prefix
. $title
. qq( [#$number](${Issue_URL}${number})\n)
);
$format eq 'html' and print encode_utf8( $prefix
. $title
. qq[ <a href="${Issue_URL}${number}">#${number}</a></li>\n]
);
. qq[ <a href="${Issue_URL}${number}">#${number}</a>] );
if ( my $related = $issue->{related_issues} ) {
my %uniq = map { $_ => 1 } @$related;
print keys %uniq > 1
? " (issues: "
: " (issue: ";
print join ", ",
map {qq[<a href="${Issue_URL}${_}">#${_}</a>]}
sort keys %uniq;
print ")";
}
print "</li>\n";
}
if ($format eq 'html' && $header && @$header_issues > 1 ) {
print "</li></ul></li>\n";
if ($header) {
print "</ul></li>\n";
}
}
$format eq 'html' and print "</ul>";
print "\n\n"
print "</ul>";
print "\n\n";
}
}
@ -116,6 +117,7 @@ sub fetch_issues {
#===================================
my $version = shift;
my @issues;
my %seen;
for my $state ( 'open', 'closed' ) {
my $page = 1;
while (1) {
@ -128,15 +130,25 @@ sub fetch_issues {
. '&page='
. $page )
or die "Couldn't fetch issues for version '$version'";
last unless @$tranche;
push @issues, @$tranche;
for my $issue (@$tranche) {
next unless $issue->{pull_request};
for ( $issue->{body} =~ m{(?:#|${User_Repo}issues/)(\d+)}g ) {
$seen{$_}++;
$issue->{related_issues} ||= [];
push @{$issue}{related_issues}, $_;
}
}
$page++;
last unless @$tranche;
}
}
my %group;
ISSUE:
for my $issue (@issues) {
next if $seen{ $issue->{number} } && !$issue->{pull_request};
my %labels = map { $_->{name} => 1 } @{ $issue->{labels} };
my $header = $issue->{title} =~ s/^([^:]+):\s+// ? $1 : '';
for (@Groups) {