master
1#!/usr/bin/env perl
2#***************************************************************************
3# _ _ ____ _
4# Project ___| | | | _ \| |
5# / __| | | | |_) | |
6# | (__| |_| | _ <| |___
7# \___|\___/|_| \_\_____|
8#
9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10#
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
13# are also available at https://curl.se/docs/copyright.html.
14#
15# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# copies of the Software, and permit persons to whom the Software is
17# furnished to do so, under the terms of the COPYING file.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22# SPDX-License-Identifier: curl
23#
24###########################################################################
26###############################################
27#
28# ==== How to use this script ====
29#
30# 1. Get recent commits added to RELEASE-NOTES:
31#
32# $ ./scripts/release-notes.pl
33#
34# 2. Edit RELEASE-NOTES and remove all entries that do not belong. Unused
35# references below are cleaned up in the next step. Make sure to move
36# "changes" up to the changes section. All entries are by default listed
37# under bug-fixes as this script cannot know where to put them.
38#
39# 3. Run the cleanup script and let it sort the entries and remove unused
40# references from lines you removed in step (2):
41#
42# $ ./scripts/release-notes.pl cleanup
43#
44# 4. Reload RELEASE-NOTES and verify that things look okay. The cleanup
45# procedure can and should be re-run when lines are removed or rephrased.
46#
47# 5. Run ./scripts/contributors.sh and update the contributor list of names
48# The list can also be extended or edited manually.
49#
50# 6. Run ./scripts/delta and update the contributor count at the top, and
51# double-check/update the other counters.
52#
53# 7. Commit the file using "RELEASE-NOTES: synced" as commit message.
54#
55################################################
57use strict;
58use warnings;
60my $cleanup = (@ARGV && $ARGV[0] eq "cleanup");
61my @gitlog = qx(git log @^{/RELEASE-NOTES:.synced}..) if(!$cleanup);
62my @releasenotes = qx(cat RELEASE-NOTES);
64my @o; # the entire new RELEASE-NOTES
65my @refused; # [num] = [2 bits of use info]
66my @refs; # [number] = [URL]
67my %dupe;
68for my $l (@releasenotes) {
69 if($l =~ /^ o .*\[(\d+)\]/) {
70 # referenced, set bit 0
71 $refused[$1] = 1;
72 my $m = $l;
73 chomp $m;
74 $m =~ s/^ o //;
75 $m =~ s/ \[\d+\]$//;
76 $dupe{$m} = 1; # mark this as present
77 }
78 elsif($l =~ /^ \[(\d+)\] = (.*)/) {
79 # listed in a reference, set bit 1
80 $refused[$1] |= 2;
81 $refs[$1] = $2;
82 }
83 # mention without reference
84 elsif($l =~ /^ o (.*)/) {
85 my $m = $l;
86 chomp $m;
87 $m =~ s/^ o //;
88 $dupe{$m} = 1; # mark this as present
89 }
90}
92# Return a new fresh reference number
93sub getref {
94 for my $r (1 .. $#refs) {
95 if(!$refused[$r] & 1) {
96 return $r;
97 }
98 }
99 # add at the end
100 return $#refs + 1;
101}
103# '#num'
104# 'num'
105# 'https://github.com/curl/curl/issues/6939'
106# 'https://github.com/curl/curl-www/issues/69'
107# 'https://elsewhere.example.com/discussion'
109sub extract {
110 my ($ref) = @_;
111 if($ref =~ /^(\#|)(\d+)/) {
112 # return the plain number
113 return $2;
114 }
115 elsif($ref =~ /^https:\/\/github.com\/curl\/curl\/.*\/(\d+)/) {
116 # return the plain number
117 return $1;
118 }
119 elsif($ref =~ /:\/\//) {
120 # contains a '://', return the URL
121 return $ref;
122 }
123 # false alarm, not a valid line
124}
126my @fixes;
127my @closes;
128my @bug;
129my @line;
130my %moreinfo;
132my $short;
133my $first;
134for my $l (@gitlog) {
135 chomp $l;
136 if($l =~ /^commit/) {
137 if($first) {
138 onecommit($short);
139 }
140 # starts a new commit
141 undef @fixes;
142 undef @closes;
143 undef @bug;
144 $short = "";
145 $first = 0;
146 }
147 elsif(($l =~ /^ (.*)/) && !$first) {
148 # first line
149 $short = $1;
150 $short =~ s/ ?\[(ci skip|skip ci)\]//g;
151 $first = 1;
152 push @line, $short;
153 }
154 elsif(($l =~ /^ (.*)/) && $first) {
155 # not the first
156 my $line = $1;
158 if($line =~ /^Fixes(:|) *(.*)/i) {
159 my $ref = extract($2);
160 push @fixes, $ref if($ref);
161 }
162 elsif($line =~ /^Cl([os]+)es(:|) *(.*)/i) {
163 my $ref = extract($3);
164 push @closes, $ref if($ref);
165 }
166 elsif($line =~ /^Bug: (.*)/i) {
167 my $ref = extract($1);
168 push @bug, $ref if($ref);
169 }
170 }
171}
172if($first) {
173 onecommit($short);
174}
176# call at the end of a parsed commit
177sub onecommit {
178 my ($short) = @_;
179 my $ref = '';
181 if($dupe{$short}) {
182 # this git commit message was found in the file
183 return;
184 }
186 if($bug[0]) {
187 $ref = $bug[0];
188 }
189 elsif($fixes[0]) {
190 $ref = $fixes[0];
191 }
192 elsif($closes[0]) {
193 $ref = $closes[0];
194 }
196 if($ref =~ /^#?(\d+)/) {
197 $ref = "https://curl.se/bug/?i=$1"
198 }
199 if($ref) {
200 my $r = getref();
201 $refs[$r] = $ref;
202 $moreinfo{$short} = $r;
203 $refused[$r] |= 1;
204 }
205}
207#### Output the new RELEASE-NOTES
209my @bullets;
210for my $l (@releasenotes) {
211 if(($l =~ /^This release includes the following bugfixes:/) && !$cleanup) {
212 push @o, $l;
213 push @o, "\n";
214 for my $f (@line) {
215 if($dupe{$f}) {
216 # this item is already listed
217 next;
218 }
220 push @o, sprintf " o %s%s\n", $f,
221 $moreinfo{$f}? sprintf(" [%d]", $moreinfo{$f}): "";
222 if($moreinfo{$f}) {
223 $refused[$moreinfo{$f}] = 3;
224 }
225 }
226 push @o, " --- new entries are listed above this ---";
227 next;
228 }
229 elsif($cleanup) {
230 if($l =~ /^ --- new entries are listed/) {
231 # ignore this if still around
232 next;
233 }
234 elsif($l =~ /^ o .*/) {
235 push @bullets, $l;
236 next;
237 }
238 elsif($bullets[0]) {
239 # output them case insensitively
240 for my $b (sort { "\L$a" cmp "\L$b" } @bullets) {
241 push @o, $b;
242 }
243 undef @bullets;
244 }
245 }
246 if($l =~ /^ \[(\d+)\] = /) {
247 # stop now
248 last;
249 }
250 else {
251 push @o, $l;
252 }
253}
255my @srefs;
256my $ln;
257for my $n (1 .. $#refs) {
258 my $r = $refs[$n];
259 if($r && ($refused[$n] & 1)) {
260 push @o, sprintf " [%d] = %s\n", $n, $r;
261 }
262}
264open(O, ">", 'RELEASE-NOTES');
265for my $l (@o) {
266 print O $l;
267}
268close(O);
270exit;
272# Debug: show unused references
273for my $r (1 .. $#refs) {
274 if($refused[$r] != 3) {
275 printf "%s is %d!\n", $r, $refused[$r];
276 }
277}
Diagnostics4 git calls · 185 ms
CallStatusSizeTime0185 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2002.6 KiB179 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=179 git.response.bytes=2679 git.response.cache=MISS git.response.duration_ms=179 git.fetch.wants=706f34435919518c22ff78f6ed2e3019809e2dec git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2679 git.pkt.payload.max=2658 git.sideband.band1.bytes=2657 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e23819ae83a594
- Request
- c23fcde2…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format