2021-08-21 18:57:11 +08:00
|
|
|
#!/usr/bin/env perl
|
2020-04-06 22:20:27 +08:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2022-02-02 21:14:44 +08:00
|
|
|
# Copyright (C) 2020 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2020-04-06 22:20:27 +08:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2020-04-06 22:20:27 +08:00
|
|
|
#
|
|
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
|
|
#
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, either express or implied.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: curl
|
2022-05-17 17:16:50 +08:00
|
|
|
#
|
2020-04-06 22:20:27 +08:00
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
###############################################
|
|
|
|
#
|
|
|
|
# ==== How to use this script ====
|
|
|
|
#
|
|
|
|
# 1. Get recent commits added to RELEASE-NOTES:
|
|
|
|
#
|
2020-04-07 05:45:31 +08:00
|
|
|
# $ ./scripts/release-notes.pl
|
2020-04-06 22:20:27 +08:00
|
|
|
#
|
2020-04-08 20:51:53 +08:00
|
|
|
# 2. Edit RELEASE-NOTES and remove all entries that don't belong. Unused
|
|
|
|
# references below will be cleaned up in the next step. Make sure to move
|
|
|
|
# "changes" up to the changes section. All entries will by default be listed
|
|
|
|
# under bug-fixes as this script can't know where to put them.
|
2020-04-06 22:20:27 +08:00
|
|
|
#
|
|
|
|
# 3. Run the cleanup script and let it sort the entries and remove unused
|
|
|
|
# references from lines you removed in step (2):
|
|
|
|
#
|
2021-07-11 04:36:26 +08:00
|
|
|
# $ ./scripts/release-notes.pl cleanup
|
2020-04-06 22:20:27 +08:00
|
|
|
#
|
|
|
|
# 4. Reload RELEASE-NOTES and verify that things look okay. The cleanup
|
|
|
|
# procedure can and should be re-run when lines are removed or rephrased.
|
|
|
|
#
|
|
|
|
# 5. Run ./scripts/contributors.sh and update the contributor list of names
|
|
|
|
# The list can also be extended or edited manually.
|
|
|
|
#
|
|
|
|
# 6. Run ./scripts/delta and update the contributor count at the top, and
|
|
|
|
# double-check/update the other counters.
|
|
|
|
#
|
|
|
|
# 7. Commit the file using "RELEASE-NOTES: synced" as commit message.
|
|
|
|
#
|
|
|
|
################################################
|
|
|
|
|
|
|
|
my $cleanup = ($ARGV[0] eq "cleanup");
|
|
|
|
my @gitlog=`git log @^{/RELEASE-NOTES:.synced}..` if(!$cleanup);
|
|
|
|
my @releasenotes=`cat RELEASE-NOTES`;
|
|
|
|
|
2020-04-08 20:51:53 +08:00
|
|
|
my @o; # the entire new RELEASE-NOTES
|
|
|
|
my @refused; # [num] = [2 bits of use info]
|
|
|
|
my @refs; # [number] = [URL]
|
2020-04-06 22:20:27 +08:00
|
|
|
for my $l (@releasenotes) {
|
|
|
|
if($l =~ /^ o .*\[(\d+)\]/) {
|
2020-04-08 20:51:53 +08:00
|
|
|
# referenced, set bit 0
|
2020-04-06 22:20:27 +08:00
|
|
|
$refused[$1]=1;
|
|
|
|
}
|
2020-04-07 05:45:31 +08:00
|
|
|
elsif($l =~ /^ \[(\d+)\] = (.*)/) {
|
2020-05-26 03:44:04 +08:00
|
|
|
# listed in a reference, set bit 1
|
2020-04-06 22:20:27 +08:00
|
|
|
$refused[$1] |= 2;
|
2020-04-08 20:51:53 +08:00
|
|
|
$refs[$1] = $2;
|
2020-04-06 22:20:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 20:51:53 +08:00
|
|
|
# Return a new fresh reference number
|
2020-04-06 22:20:27 +08:00
|
|
|
sub getref {
|
2020-04-08 20:51:53 +08:00
|
|
|
for my $r (1 .. $#refs) {
|
2020-04-06 22:20:27 +08:00
|
|
|
if(!$refused[$r] & 1) {
|
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# add at the end
|
2020-04-08 20:51:53 +08:00
|
|
|
return $#refs + 1;
|
2020-04-06 22:20:27 +08:00
|
|
|
}
|
|
|
|
|
2021-11-05 07:09:51 +08:00
|
|
|
# '#num'
|
|
|
|
# 'num'
|
|
|
|
# 'https://github.com/curl/curl/issues/6939'
|
|
|
|
# 'https://github.com/curl/curl-www/issues/69'
|
|
|
|
|
|
|
|
sub extract {
|
|
|
|
my ($ref)=@_;
|
|
|
|
if($ref =~ /^(\#|)(\d+)/) {
|
|
|
|
# return the plain number
|
|
|
|
return $2;
|
|
|
|
}
|
|
|
|
elsif($ref =~ /^https:\/\/github.com\/curl\/curl\/.*\/(\d+)/) {
|
|
|
|
# return the plain number
|
2022-02-02 21:14:44 +08:00
|
|
|
return $1;
|
2021-11-05 07:09:51 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
# return the URL
|
|
|
|
return $ref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-06 22:20:27 +08:00
|
|
|
my $short;
|
|
|
|
my $first;
|
|
|
|
for my $l (@gitlog) {
|
|
|
|
chomp $l;
|
|
|
|
if($l =~ /^commit/) {
|
|
|
|
if($first) {
|
|
|
|
onecommit($short);
|
|
|
|
}
|
|
|
|
# starts a new commit
|
|
|
|
undef @fixes;
|
|
|
|
undef @closes;
|
|
|
|
undef @bug;
|
|
|
|
$short = "";
|
|
|
|
$first = 0;
|
|
|
|
}
|
|
|
|
elsif(($l =~ /^ (.*)/) && !$first) {
|
|
|
|
# first line
|
|
|
|
$short = $1;
|
2022-10-03 06:15:21 +08:00
|
|
|
$short =~ s/ ?\[(ci skip|skip ci)\]//g;
|
2020-04-06 22:20:27 +08:00
|
|
|
$first = 1;
|
|
|
|
push @line, $short;
|
|
|
|
}
|
|
|
|
elsif(($l =~ /^ (.*)/) && $first) {
|
|
|
|
# not the first
|
|
|
|
my $line = $1;
|
|
|
|
|
2021-11-05 07:09:51 +08:00
|
|
|
if($line =~ /^Fixes(:|) *(.*)/i) {
|
|
|
|
push @fixes, extract($2);
|
2020-04-06 22:20:27 +08:00
|
|
|
}
|
2021-11-05 07:09:51 +08:00
|
|
|
elsif($line =~ /^Clo(s|)es(:|) *(.*)/i) {
|
|
|
|
push @closes, extract($3);
|
2020-04-06 22:20:27 +08:00
|
|
|
}
|
|
|
|
elsif($line =~ /^Bug: (.*)/i) {
|
2021-11-05 07:09:51 +08:00
|
|
|
push @bug, extract($1);
|
2020-04-06 22:20:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($first) {
|
|
|
|
onecommit($short);
|
|
|
|
}
|
|
|
|
|
|
|
|
# call at the end of a parsed commit
|
|
|
|
sub onecommit {
|
|
|
|
my ($short)=@_;
|
|
|
|
my $ref;
|
|
|
|
|
|
|
|
if($bug[0]) {
|
|
|
|
$ref = $bug[0];
|
|
|
|
}
|
|
|
|
elsif($fixes[0]) {
|
|
|
|
$ref = $fixes[0];
|
|
|
|
}
|
|
|
|
elsif($closes[0]) {
|
|
|
|
$ref = $closes[0];
|
|
|
|
}
|
|
|
|
|
2020-11-13 20:17:16 +08:00
|
|
|
if($ref =~ /^#?(\d+)/) {
|
2020-11-04 21:02:01 +08:00
|
|
|
$ref = "https://curl.se/bug/?i=$1"
|
2020-04-06 22:20:27 +08:00
|
|
|
}
|
|
|
|
if($ref) {
|
|
|
|
my $r = getref();
|
|
|
|
$refs[$r] = $ref;
|
|
|
|
$moreinfo{$short}=$r;
|
|
|
|
$refused[$r] |= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#### Output the new RELEASE-NOTES
|
|
|
|
|
|
|
|
my @bullets;
|
|
|
|
for my $l (@releasenotes) {
|
|
|
|
if(($l =~ /^This release includes the following bugfixes:/) && !$cleanup) {
|
|
|
|
push @o, $l;
|
|
|
|
push @o, "\n";
|
|
|
|
for my $f (@line) {
|
2020-10-05 14:29:28 +08:00
|
|
|
push @o, sprintf " o %s%s\n", $f,
|
|
|
|
$moreinfo{$f}? sprintf(" [%d]", $moreinfo{$f}): "";
|
2020-04-06 22:20:27 +08:00
|
|
|
$refused[$moreinfo{$f}]=3;
|
|
|
|
}
|
|
|
|
push @o, " --- new entries are listed above this ---";
|
2020-04-14 20:57:46 +08:00
|
|
|
next;
|
2020-04-06 22:20:27 +08:00
|
|
|
}
|
|
|
|
elsif($cleanup) {
|
|
|
|
if($l =~ /^ --- new entries are listed/) {
|
|
|
|
# ignore this if still around
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^ o .*/) {
|
|
|
|
push @bullets, $l;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif($bullets[0]) {
|
|
|
|
# output them case insensitively
|
|
|
|
for my $b (sort { "\L$a" cmp "\L$b" } @bullets) {
|
|
|
|
push @o, $b;
|
|
|
|
}
|
|
|
|
undef @bullets;
|
|
|
|
}
|
|
|
|
}
|
2020-04-12 00:47:23 +08:00
|
|
|
if($l =~ /^ \[(\d+)\] = /) {
|
2020-04-08 20:51:53 +08:00
|
|
|
# stop now
|
|
|
|
last;
|
|
|
|
}
|
2020-04-06 22:20:27 +08:00
|
|
|
else {
|
|
|
|
push @o, $l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-07 05:45:31 +08:00
|
|
|
my @srefs;
|
|
|
|
my $ln;
|
2020-04-08 20:51:53 +08:00
|
|
|
for my $n (1 .. $#refs) {
|
|
|
|
my $r = $refs[$n];
|
2020-04-07 05:45:31 +08:00
|
|
|
if($r && ($refused[$n] & 1)) {
|
2020-04-06 22:20:27 +08:00
|
|
|
push @o, sprintf " [%d] = %s\n", $n, $r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
open(O, ">RELEASE-NOTES");
|
|
|
|
for my $l (@o) {
|
|
|
|
print O $l;
|
|
|
|
}
|
|
|
|
close(O);
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
# Debug: show unused references
|
2020-04-08 20:51:53 +08:00
|
|
|
for my $r (1 .. $#refs) {
|
2020-04-06 22:20:27 +08:00
|
|
|
if($refused[$r] != 3) {
|
2020-10-05 14:29:28 +08:00
|
|
|
printf "%s is %d!\n", $r, $refused[$r];
|
2020-04-06 22:20:27 +08:00
|
|
|
}
|
|
|
|
}
|