-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Fix and enforce BIP 2 & 3 field ordering #1893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
6707c35
to
6aa4213
Compare
-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-
6aa4213
to
69d5303
Compare
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.
69d5303
to
2bcf420
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo comment
scripts/buildtable.pl
Outdated
@@ -182,13 +206,18 @@ | |||
die "Unknown field $field in $fn"; | |||
} | |||
++$found{$field}; | |||
push @field_order, $field if $field_order[-1] ne $field; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running ./scripts/buildtable.pl
on this branch, I am seeing the following messages on each iteration that were not present on master:
Use of uninitialized value in string ne at ./scripts/buildtable.pl line 209, <$F> line 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ ./scripts/buildtable.pl
Use of uninitialized value in string ne at ./scripts/buildtable.pl line 209, <$F> line 2.
|- style="background-color: #ffcfcf"
| [[bip-0001.mediawiki|1]]
|
| BIP Purpose and Guidelines
| Amir Taaki
| Process
| Replaced
Use of uninitialized value in string ne at ./scripts/buildtable.pl line 209, <$F> line 2.
|- style="background-color: #cfffcf"
| [[bip-0002.mediawiki|2]]
|
| BIP process, revised
| Luke Dashjr
| Process
| Active
Use of uninitialized value in string ne at ./scripts/buildtable.pl line 209, <$F> line 2.
|- style="background-color: #ffffcf"
| [[bip-0003.md|3]]
|
| Updated BIP Process
| Murch
| Process
| Proposed
Use of uninitialized value in string ne at ./scripts/buildtable.pl line 209, <$F> line 2.
.../...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, that was sloppy... i pushed a fixup commit, should i squash it already or would reviewing that on its own be easier?
The first commit is a scripted diff that corrects field ordering in a number of BIPs which are not consistent with the specified in BIP 2.
The second commit enforces that fields are ordered consistently with both BIP 2 and BIP 3. It does not strictly depend on #1820.