1
0
mirror of https://github.com/bitcoin/bips.git synced 2025-08-18 13:26:23 +00:00

CI: Enforce BIP 2 & 3 field ordering requirements

The specified field order is consistent with both BIPs 2 and 3. The
ordering of fields which are only present in one or the other is
ambiguous, e.g. as in `Proposed-Replacement` and `Superseded-By` but
only one of these applies to a given BIP.

The `Editor` field is spurious, only being used in BIP 69, and appears
after Author.
This commit is contained in:
Yuval Kogman 2025-07-10 01:36:29 +02:00 committed by Jon Atack
parent cd19d89e58
commit 0eb3718c5d

View File

@ -37,6 +37,30 @@ my %MiscField = (
'Requires' => undef,
'Superseded-By' => undef,
);
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 %ValidLayer = (
'Consensus (soft fork)' => undef,
@ -114,7 +138,7 @@ while (++$bipnum <= $topbip) {
}
my %found;
my ($title, $author, $status, $type, $layer);
my ($field, $val);
my ($field, $val, @field_order);
while (<$F>) {
last if ($is_markdown && m[^```$]);
last if (!$is_markdown && m[^</pre>$]);
@ -182,6 +206,7 @@ while (++$bipnum <= $topbip) {
die "Unknown field $field in $fn";
}
++$found{$field};
push @field_order, $field unless @field_order and $field_order[-1] eq $field;
}
if (not $found{License}) {
die "Missing License in $fn" unless exists $TolerateMissingLicense{$bipnum};
@ -189,6 +214,10 @@ while (++$bipnum <= $topbip) {
for my $field (keys %RequiredFields) {
die "Missing $field in $fn" unless $found{$field};
}
my @expected_field_order = grep { exists $found{$_} } @FieldOrder;
if ("@expected_field_order" ne "@field_order") {
die "Field order is incorrect in $fn, should be:\n\t" . join(", ", @expected_field_order) . "\nbut contains:\n\t" . join(", ", @field_order);
}
print "|-";
if (defined $ValidStatus{$status}) {
print " style=\"" . $ValidStatus{$status} . "\"";