123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- my $cleanup = ($ARGV[0] eq "cleanup");
- my @gitlog=`git log @^{/RELEASE-NOTES:.synced}..` if(!$cleanup);
- my @releasenotes=`cat RELEASE-NOTES`;
- my @o;
- my @refused;
- my @refs;
- for my $l (@releasenotes) {
- if($l =~ /^ o .*\[(\d+)\]/) {
-
- $refused[$1]=1;
- }
- elsif($l =~ /^ \[(\d+)\] = (.*)/) {
-
- $refused[$1] |= 2;
- $refs[$1] = $2;
- }
- }
- sub getref {
- for my $r (1 .. $#refs) {
- if(!$refused[$r] & 1) {
- return $r;
- }
- }
-
- return $#refs + 1;
- }
- sub extract {
- my ($ref)=@_;
- if($ref =~ /^(\#|)(\d+)/) {
-
- return $2;
- }
- elsif($ref =~ /^https:\/\/github.com\/curl\/curl\/.*\/(\d+)/) {
-
- return $1;
- }
- elsif($ref =~ /:\/\//) {
-
- return $ref;
- }
-
- }
- my $short;
- my $first;
- for my $l (@gitlog) {
- chomp $l;
- if($l =~ /^commit/) {
- if($first) {
- onecommit($short);
- }
-
- undef @fixes;
- undef @closes;
- undef @bug;
- $short = "";
- $first = 0;
- }
- elsif(($l =~ /^ (.*)/) && !$first) {
-
- $short = $1;
- $short =~ s/ ?\[(ci skip|skip ci)\]//g;
- $first = 1;
- push @line, $short;
- }
- elsif(($l =~ /^ (.*)/) && $first) {
-
- my $line = $1;
- if($line =~ /^Fixes(:|) *(.*)/i) {
- my $ref = extract($2);
- push @fixes, $ref if($ref);
- }
- elsif($line =~ /^Clo(s|)es(:|) *(.*)/i) {
- my $ref = extract($3);
- push @closes, $ref if($ref);
- }
- elsif($line =~ /^Bug: (.*)/i) {
- my $ref = extract($1);
- push @bug, $ref if($ref);
- }
- }
- }
- if($first) {
- onecommit($short);
- }
- sub onecommit {
- my ($short)=@_;
- my $ref;
- if($bug[0]) {
- $ref = $bug[0];
- }
- elsif($fixes[0]) {
- $ref = $fixes[0];
- }
- elsif($closes[0]) {
- $ref = $closes[0];
- }
- if($ref =~ /^#?(\d+)/) {
- $ref = "https://curl.se/bug/?i=$1"
- }
- if($ref) {
- my $r = getref();
- $refs[$r] = $ref;
- $moreinfo{$short}=$r;
- $refused[$r] |= 1;
- }
- }
- 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) {
- push @o, sprintf " o %s%s\n", $f,
- $moreinfo{$f}? sprintf(" [%d]", $moreinfo{$f}): "";
- $refused[$moreinfo{$f}]=3;
- }
- push @o, " --- new entries are listed above this ---";
- next;
- }
- elsif($cleanup) {
- if($l =~ /^ --- new entries are listed/) {
-
- next;
- }
- elsif($l =~ /^ o .*/) {
- push @bullets, $l;
- next;
- }
- elsif($bullets[0]) {
-
- for my $b (sort { "\L$a" cmp "\L$b" } @bullets) {
- push @o, $b;
- }
- undef @bullets;
- }
- }
- if($l =~ /^ \[(\d+)\] = /) {
-
- last;
- }
- else {
- push @o, $l;
- }
- }
- my @srefs;
- my $ln;
- for my $n (1 .. $#refs) {
- my $r = $refs[$n];
- if($r && ($refused[$n] & 1)) {
- push @o, sprintf " [%d] = %s\n", $n, $r;
- }
- }
- open(O, ">RELEASE-NOTES");
- for my $l (@o) {
- print O $l;
- }
- close(O);
- exit;
- for my $r (1 .. $#refs) {
- if($refused[$r] != 3) {
- printf "%s is %d!\n", $r, $refused[$r];
- }
- }
|