Skip to content

Commit 2bcf420

Browse files
committed
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.
1 parent cfd5d59 commit 2bcf420

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

scripts/buildtable.pl

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@
3737
'Requires' => undef,
3838
'Superseded-By' => undef,
3939
);
40+
my @FieldOrder = qw(
41+
BIP
42+
Layer
43+
Title
44+
Author
45+
Authors
46+
Editor
47+
Deputies
48+
Discussions-To
49+
Comments-Summary
50+
Comments-URI
51+
Status
52+
Type
53+
Created
54+
License
55+
License-Code
56+
Discussion
57+
Post-History
58+
Version
59+
Requires
60+
Replaces
61+
Proposed-Replacement
62+
Superseded-By
63+
);
4064

4165
my %ValidLayer = (
4266
'Consensus (soft fork)' => undef,
@@ -114,7 +138,7 @@
114138
}
115139
my %found;
116140
my ($title, $author, $status, $type, $layer);
117-
my ($field, $val);
141+
my ($field, $val, @field_order);
118142
while (<$F>) {
119143
last if ($is_markdown && m[^```$]);
120144
last if (!$is_markdown && m[^</pre>$]);
@@ -182,13 +206,18 @@
182206
die "Unknown field $field in $fn";
183207
}
184208
++$found{$field};
209+
push @field_order, $field if $field_order[-1] ne $field;
185210
}
186211
if (not $found{License}) {
187212
die "Missing License in $fn" unless exists $TolerateMissingLicense{$bipnum};
188213
}
189214
for my $field (keys %RequiredFields) {
190215
die "Missing $field in $fn" unless $found{$field};
191216
}
217+
my @expected_field_order = grep { exists $found{$_} } @FieldOrder;
218+
if ("@expected_field_order" ne "@field_order") {
219+
die "Field order is incorrect in $fn, should be:\n\t" . join(", ", @expected_field_order) . "\nbut contains:\n\t" . join(", ", @field_order);
220+
}
192221
print "|-";
193222
if (defined $ValidStatus{$status}) {
194223
print " style=\"" . $ValidStatus{$status} . "\"";

0 commit comments

Comments
 (0)