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=begin comment
28This script updates a curldown file to current/better curldown.
30Example: cd2cd [--in-place] <file.md> > <file.md>
32--in-place: if used, it replaces the original file with the cleaned up
33 version. When this is used, cd2cd accepts multiple files to work
34 on and it ignores errors on single files.
36=end comment
37=cut
39use strict;
40use warnings;
42my $cd2cd = "0.1"; # to keep check
43my $dir;
44my $extension;
45my $inplace = 0;
47while(1) {
48 if(@ARGV && $ARGV[0] eq "--in-place") {
49 shift @ARGV;
50 $inplace = 1;
51 }
52 else {
53 last;
54 }
55}
57use POSIX qw(strftime);
58my @ts;
59if(defined($ENV{SOURCE_DATE_EPOCH})) {
60 @ts = localtime($ENV{SOURCE_DATE_EPOCH});
61}
62else {
63 @ts = localtime;
64}
65my $date = strftime "%B %d %Y", @ts;
67sub outseealso {
68 my (@sa) = @_;
69 my $comma = 0;
70 my @o;
71 push @o, ".SH SEE ALSO\n";
72 for my $s (sort @sa) {
73 push @o, sprintf "%s.BR $s", $comma ? ",\n" : "";
74 $comma = 1;
75 }
76 push @o, "\n";
77 return @o;
78}
80sub single {
81 my @head;
82 my @seealso;
83 my ($f) = @_;
84 my $title;
85 my $section;
86 my $source;
87 my $start = 0;
88 my $d;
89 my $line = 0;
90 my $salist = 0;
91 my $copyright;
92 my $spdx;
93 open(F, "<:crlf", $f) or
94 return 1;
95 while(<F>) {
96 $line++;
97 $d = $_;
98 if(!$start) {
99 if(/^---/) {
100 # header starts here
101 $start = 1;
102 push @head, $d;
103 }
104 next;
105 }
106 if(/^Title: *(.*)/i) {
107 $title = $1;
108 }
109 elsif(/^Section: *(.*)/i) {
110 $section = $1;
111 }
112 elsif(/^Source: *(.*)/i) {
113 $source = $1;
114 }
115 elsif(/^See-also: +(.*)/i) {
116 $salist = 0;
117 push @seealso, $1;
118 }
119 elsif(/^See-also: */i) {
120 if($seealso[0]) {
121 print STDERR "$f:$line:1:ERROR: bad See-Also, needs list\n";
122 return 2;
123 }
124 $salist = 1;
125 }
126 elsif(/^ +- (.*)/i) {
127 # the only list we support is the see-also
128 if($salist) {
129 push @seealso, $1;
130 }
131 }
132 # REUSE-IgnoreStart
133 elsif(/^C: (.*)/i) {
134 $copyright = $1;
135 }
136 elsif(/^SPDX-License-Identifier: (.*)/i) {
137 $spdx = $1;
138 }
139 # REUSE-IgnoreEnd
140 elsif(/^---/) {
141 # end of the header section
142 if(!$title) {
143 print STDERR "ERROR: no 'Title:' in $f\n";
144 return 1;
145 }
146 if(!$section) {
147 print STDERR "ERROR: no 'Section:' in $f\n";
148 return 2;
149 }
150 if(!$seealso[0]) {
151 print STDERR "$f:$line:1:ERROR: no 'See-also:' present\n";
152 return 2;
153 }
154 if(!$copyright) {
155 print STDERR "$f:$line:1:ERROR: no 'C:' field present\n";
156 return 2;
157 }
158 if(!$spdx) {
159 # REUSE-IgnoreStart
160 print STDERR "$f:$line:1:ERROR: no 'SPDX-License-Identifier:' field present\n";
161 # REUSE-IgnoreEnd
162 return 2;
163 }
164 last;
165 }
166 else {
167 chomp;
168 print STDERR "WARN: unrecognized line in $f, ignoring:\n:'$_';"
169 }
170 }
172 if(!$start) {
173 print STDERR "$f:$line:1:ERROR: no header present\n";
174 return 2;
175 }
177 my @desc;
179 push @desc, sprintf <<HEAD
180---
181c: Copyright (C) Daniel Stenberg, <daniel\@haxx.se>, et al.
182SPDX-License-Identifier: curl
183Title: $title
184Section: $section
185Source: $source
186HEAD
187 ;
188 push @desc, "See-also:\n";
189 for my $s (sort @seealso) {
190 push @desc, " - $s\n" if($s);
191 }
192 push @desc, "---\n";
194 my $blankline = 0;
195 while(<F>) {
196 $d = $_;
197 $line++;
198 if($d =~ /^[ \t]*\n/) {
199 $blankline++;
200 }
201 else {
202 $blankline = 0;
203 }
204 # *italics* for curl symbol links get the asterisks removed
205 $d =~ s/\*((lib|)curl[^ ]*\(3\))\*/$1/gi;
207 if(length($d) > 90) {
208 print STDERR "$f:$line:1:WARN: excessive line length\n";
209 }
211 push @desc, $d if($blankline < 2);
212 }
213 close(F);
215 if($inplace) {
216 open(O, ">", $f) or return 1;
217 print O @desc;
218 close(O);
219 }
220 else {
221 print @desc;
222 }
223 return 0;
224}
226if($inplace) {
227 for my $a (@ARGV) {
228 # this ignores errors
229 single($a);
230 }
231}
232elsif(@ARGV) {
233 exit single($ARGV[0]);
234}
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 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 · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 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 · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=26 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 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.0 KiB · hit26 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2088 git.response.cache=HIT git.response.duration_ms=26 git.fetch.wants=491544b908220ebddfe2db5ed68e6c86592a5efa 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=2088 git.pkt.payload.max=2067 git.sideband.band1.bytes=2066 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
- a5e130126beca9fe
- Request
- 788ff693…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format