1
0
mirror of https://github.com/bitcoin/bips.git synced 2025-07-21 12:58:14 +00:00

scripted-diff: fix BIP 2 field order violations

-BEGIN VERIFY SCRIPT-
set -e
perl <<'-END PERL-'
use strict;
use warnings;

my $topbip = 9999;

my @FieldOrder = qw(
	BIP
	Layer
	Title
	Author
	Authors
	Editor
	Deputies
	Discussions-To
	Comments-Summary
	Comments-URI
	Status
	Type
	Created
	License
	License-Code
	Discussion
	Post-History
	Version
	Requires
	Replaces
	Proposed-Replacement
	Superseded-By
);

my $bipnum = 0;
while (++$bipnum <= $topbip) {
	my $fn = sprintf "bip-%04d.mediawiki", $bipnum;
	my $is_markdown = 0;
	if (!-e $fn) {
		$fn = sprintf "bip-%04d.md", $bipnum;
		$is_markdown = 1;
	}
	-e $fn || next;
	open my $F, "<", $fn or die "$!";

	my (@before, %preamble, @after);

	if ($is_markdown) {
		while (<$F>) {
			push @before, $_;
			last if m[^(?:\xef\xbb\xbf)?```$]
		}
		die "No ``` in $fn" if eof $F;
	} else {
		while (<$F>) {
			push @before, $_;
			last if m[^(?:\xef\xbb\xbf)?<pre>$];
		}
		die "No <pre> in $fn" if eof $F;
	}
	my %found;
	my ($title, $author, $status, $type, $layer);
	my ($field, $val, @field_order);
	while (<$F>) {
		push @after, $_ and last if ($is_markdown && m[^```$]);
		push @after, $_ and last if (!$is_markdown && m[^</pre>$]);

		if (m[^  ([\w-]+)\: (.*\S)$]) {
			$field = $1;
			$val = $2;
		} elsif (m[^  ( +)(.*\S)$]) {
			$val = $2;
		} else {
			die "Bad line in $fn preamble";
		}

		push @{$preamble{$field} ||= []}, $_;
	}
	push @after, <$F>;
	close $F or die $!;

	open my $W, ">", "$fn" or die "$!";

	print $W @before;
	print $W map { @$_ } grep { defined } delete @preamble{@FieldOrder};
	die "Unknown fields: @{[ keys %preamble ]}" if %preamble;
	print $W @after;

	close $W or die $!;
}
-END PERL-
-END VERIFY SCRIPT-
This commit is contained in:
Yuval Kogman 2025-07-10 02:24:55 +02:00 committed by Jon Atack
parent 340c1a3d53
commit cd19d89e58
9 changed files with 13 additions and 13 deletions

View File

@ -5,13 +5,13 @@
Author: Dan Gould <d@ngould.dev>
Yuval Kogman <nothingmuch@woobling.org>
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0077
Post-History: https://github.com/bitcoin/bips/pull/1483
https://gnusha.org/pi/bitcoindev/7B11AE34-27A7-46ED-95BF-66CA13BA26F3@ngould.dev/#t
https://gnusha.org/pi/bitcoindev/3C0A6E4C-444E-4E75-829C-1A21D8EE40E0@ngould.dev/#t
Status: Draft
Type: Standards Track
Created: 2023-08-08
License: BSD-2-Clause
Post-History: https://github.com/bitcoin/bips/pull/1483
https://gnusha.org/pi/bitcoindev/7B11AE34-27A7-46ED-95BF-66CA13BA26F3@ngould.dev/#t
https://gnusha.org/pi/bitcoindev/3C0A6E4C-444E-4E75-829C-1A21D8EE40E0@ngould.dev/#t
Requires: 21, 78, 173, 174
```

View File

@ -3,13 +3,13 @@
Layer: Applications
Title: A Simple Payjoin Proposal
Author: Nicolas Dorier <nicolas.dorier@gmail.com>
Replaces: 79
Comments-Summary: No comments yet.
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0078
Status: Draft
Type: Standards Track
Created: 2019-05-01
License: BSD-2-Clause
Replaces: 79
</pre>
==Introduction==

View File

@ -3,10 +3,10 @@
Layer: Applications
Title: Anti-fee-sniping in taproot transactions
Author: Chris Belcher <belcher@riseup.net>
Status: Draft
Type: Informational
Comments-Summary: No comments yet.
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0326
Status: Draft
Type: Informational
Created: 2021-06-10
License: CC0-1.0
Post-History: 2021-6-10: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-June/019048.html

View File

@ -4,13 +4,13 @@
Author: Jonas Nick <jonasd.nick@gmail.com>
Tim Ruffing <crypto@timruffing.de>
Elliott Jin <elliott.jin@gmail.com>
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0327
Status: Active
License: BSD-3-Clause
Type: Informational
Created: 2022-03-22
License: BSD-3-Clause
Post-History: 2022-04-05: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-April/020198.html [bitcoin-dev] MuSig2 BIP
2022-10-11: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-October/021000.html [bitcoin-dev] MuSig2 BIP
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0327
</pre>
== Introduction ==

View File

@ -8,11 +8,11 @@
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0340
Status: Final
Type: Standards Track
Created: 2020-01-19
License: BSD-2-Clause
License-Code: BSD-2-Clause
MIT
CC0-1.0
Created: 2020-01-19
Post-History: 2018-07-06: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-July/016203.html [bitcoin-dev] Schnorr signatures BIP
</pre>

View File

@ -11,9 +11,9 @@
Type: Standards Track
Created: 2020-01-19
License: BSD-3-Clause
Requires: 340
Post-History: 2019-05-06: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-May/016914.html [bitcoin-dev] Taproot proposal
2019-10-09: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-October/017378.html [bitcoin-dev] Taproot updates
Requires: 340
</pre>
==Introduction==

View File

@ -11,8 +11,8 @@
Type: Standards Track
Created: 2020-01-19
License: BSD-3-Clause
Requires: 340, 341
Post-History: 2019-05-06: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-May/016914.html [bitcoin-dev] Taproot proposal
Requires: 340, 341
</pre>
==Introduction==

View File

@ -9,8 +9,8 @@
Type: Standards Track
Created: 2020-12-16
License: BSD-2-Clause
Replaces: 173
Post-History: 2021-01-05: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-January/018338.html [bitcoin-dev] Bech32m BIP: new checksum, and usage for segwit address
Replaces: 173
</pre>
==Introduction==

View File

@ -8,8 +8,8 @@
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0374
Status: Draft
Type: Standards Track
License: BSD-2-Clause
Created: 2024-12-26
License: BSD-2-Clause
Post-History: https://gist.github.com/andrewtoth/df97c3260cc8d12f09d3855ee61322ea
https://groups.google.com/g/bitcoindev/c/MezoKV5md7s
</pre>