@biffo/cli 0.322.1 → 0.323.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -441,6 +441,51 @@ def _legacy_key(k: str) -> str:
|
|
|
441
441
|
return k
|
|
442
442
|
|
|
443
443
|
|
|
444
|
+
def _is_v2_key(k: str) -> bool:
|
|
445
|
+
"""True when `k` is a v2 `path:line:kind:label` key (second field all digits)."""
|
|
446
|
+
return _legacy_key(k) != k
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def _known(keys: list[str], recorded: set[str]) -> tuple[set[str], bool]:
|
|
450
|
+
"""Which of this script's v2 `keys` the baseline already accepts.
|
|
451
|
+
|
|
452
|
+
Returns `(known, used_v1)`. `used_v1` is True when the baseline holds ANY
|
|
453
|
+
entry still in v1 form — the caller announces that, so accepting a v1
|
|
454
|
+
baseline is never silent.
|
|
455
|
+
|
|
456
|
+
Three routes to "known", each a deliberate, separate rule:
|
|
457
|
+
|
|
458
|
+
- the exact key, always (a v2 baseline's full collision-proof match, #2026);
|
|
459
|
+
- the key's v1 form, ONLY against baseline entries that are themselves v1
|
|
460
|
+
(#2102). This is the mirror of #2037's shim, which lets a v1-computing
|
|
461
|
+
script accept a v2 baseline. `shared-sync` ships this v2 script into
|
|
462
|
+
satellites whose own baseline is still v1, and it cannot regenerate that
|
|
463
|
+
baseline (it needs a coverage run inside the satellite), so without this
|
|
464
|
+
every baselined branch read NEW and the sync PR failed. Restricting it to
|
|
465
|
+
v1 entries means a v2 baseline never gains the looser match: a genuinely
|
|
466
|
+
new same-labeled branch in a v2 baseline is still NEW;
|
|
467
|
+
- `_legacy_key` of a recorded v2 entry, for #2037's opposite direction
|
|
468
|
+
(unchanged here; it is a no-op for a script that computes v2 keys).
|
|
469
|
+
|
|
470
|
+
While a v1 baseline is accepted, every branch sharing a `path:kind:label`
|
|
471
|
+
with one v1 entry is absorbed by it — #2026's collision bug, for exactly as
|
|
472
|
+
long as that baseline stays v1. That is why the acceptance is announced.
|
|
473
|
+
|
|
474
|
+
Retire the v1 route (`v1_entries` and the notice in `main()`) once every
|
|
475
|
+
inheriting repo's baseline has been regenerated as v2 (`--write`).
|
|
476
|
+
|
|
477
|
+
EXPIRY: same as `_legacy_key` above — tracked by
|
|
478
|
+
keiranholloway/biffo-template#2056 (retire once every inheriting repo's
|
|
479
|
+
baseline is v2). #2102 added the v1-baseline half of this shim; a repo
|
|
480
|
+
still carrying it after #2056 closes is exposed to the collision above.
|
|
481
|
+
Grep for "EXPIRY" in this function.
|
|
482
|
+
"""
|
|
483
|
+
v1_entries = {r for r in recorded if not _is_v2_key(r)}
|
|
484
|
+
known = set(recorded) | {_legacy_key(r) for r in recorded}
|
|
485
|
+
known |= {k for k in keys if _legacy_key(k) in v1_entries}
|
|
486
|
+
return known, bool(v1_entries)
|
|
487
|
+
|
|
488
|
+
|
|
444
489
|
def main() -> int:
|
|
445
490
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
446
491
|
parser.add_argument("--write", action="store_true", help="record the current set as baseline")
|
|
@@ -579,8 +624,20 @@ def main() -> int:
|
|
|
579
624
|
# recognises a v2-shaped baseline entry (#2037 migration shim; see
|
|
580
625
|
# `_legacy_key`). `keys` itself is left untouched.
|
|
581
626
|
recorded = set(baseline.get("branches", []))
|
|
582
|
-
known =
|
|
627
|
+
known, used_v1 = _known(keys, recorded)
|
|
583
628
|
new = [k for k in keys if k not in known]
|
|
629
|
+
if used_v1:
|
|
630
|
+
# #2102: accepted, but never silently — a v1 entry cannot tell two
|
|
631
|
+
# same-labeled branches in one file apart, so the ratchet is weaker
|
|
632
|
+
# until the baseline is regenerated.
|
|
633
|
+
print(
|
|
634
|
+
"::warning::error-branch coverage: baseline holds v1 keys "
|
|
635
|
+
"(path:kind:label) — accepted for now, but same-labeled branches "
|
|
636
|
+
"in one file are indistinguishable until it is migrated. "
|
|
637
|
+
"Run: python scripts/error_branch_coverage.py --write "
|
|
638
|
+
"(after a coverage run) and commit the baseline.",
|
|
639
|
+
file=sys.stderr,
|
|
640
|
+
)
|
|
584
641
|
|
|
585
642
|
print(
|
|
586
643
|
f"unexecuted error branches: {len(keys)} "
|
|
@@ -441,6 +441,51 @@ def _legacy_key(k: str) -> str:
|
|
|
441
441
|
return k
|
|
442
442
|
|
|
443
443
|
|
|
444
|
+
def _is_v2_key(k: str) -> bool:
|
|
445
|
+
"""True when `k` is a v2 `path:line:kind:label` key (second field all digits)."""
|
|
446
|
+
return _legacy_key(k) != k
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def _known(keys: list[str], recorded: set[str]) -> tuple[set[str], bool]:
|
|
450
|
+
"""Which of this script's v2 `keys` the baseline already accepts.
|
|
451
|
+
|
|
452
|
+
Returns `(known, used_v1)`. `used_v1` is True when the baseline holds ANY
|
|
453
|
+
entry still in v1 form — the caller announces that, so accepting a v1
|
|
454
|
+
baseline is never silent.
|
|
455
|
+
|
|
456
|
+
Three routes to "known", each a deliberate, separate rule:
|
|
457
|
+
|
|
458
|
+
- the exact key, always (a v2 baseline's full collision-proof match, #2026);
|
|
459
|
+
- the key's v1 form, ONLY against baseline entries that are themselves v1
|
|
460
|
+
(#2102). This is the mirror of #2037's shim, which lets a v1-computing
|
|
461
|
+
script accept a v2 baseline. `shared-sync` ships this v2 script into
|
|
462
|
+
satellites whose own baseline is still v1, and it cannot regenerate that
|
|
463
|
+
baseline (it needs a coverage run inside the satellite), so without this
|
|
464
|
+
every baselined branch read NEW and the sync PR failed. Restricting it to
|
|
465
|
+
v1 entries means a v2 baseline never gains the looser match: a genuinely
|
|
466
|
+
new same-labeled branch in a v2 baseline is still NEW;
|
|
467
|
+
- `_legacy_key` of a recorded v2 entry, for #2037's opposite direction
|
|
468
|
+
(unchanged here; it is a no-op for a script that computes v2 keys).
|
|
469
|
+
|
|
470
|
+
While a v1 baseline is accepted, every branch sharing a `path:kind:label`
|
|
471
|
+
with one v1 entry is absorbed by it — #2026's collision bug, for exactly as
|
|
472
|
+
long as that baseline stays v1. That is why the acceptance is announced.
|
|
473
|
+
|
|
474
|
+
Retire the v1 route (`v1_entries` and the notice in `main()`) once every
|
|
475
|
+
inheriting repo's baseline has been regenerated as v2 (`--write`).
|
|
476
|
+
|
|
477
|
+
EXPIRY: same as `_legacy_key` above — tracked by
|
|
478
|
+
keiranholloway/biffo-template#2056 (retire once every inheriting repo's
|
|
479
|
+
baseline is v2). #2102 added the v1-baseline half of this shim; a repo
|
|
480
|
+
still carrying it after #2056 closes is exposed to the collision above.
|
|
481
|
+
Grep for "EXPIRY" in this function.
|
|
482
|
+
"""
|
|
483
|
+
v1_entries = {r for r in recorded if not _is_v2_key(r)}
|
|
484
|
+
known = set(recorded) | {_legacy_key(r) for r in recorded}
|
|
485
|
+
known |= {k for k in keys if _legacy_key(k) in v1_entries}
|
|
486
|
+
return known, bool(v1_entries)
|
|
487
|
+
|
|
488
|
+
|
|
444
489
|
def main() -> int:
|
|
445
490
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
446
491
|
parser.add_argument("--write", action="store_true", help="record the current set as baseline")
|
|
@@ -579,8 +624,20 @@ def main() -> int:
|
|
|
579
624
|
# recognises a v2-shaped baseline entry (#2037 migration shim; see
|
|
580
625
|
# `_legacy_key`). `keys` itself is left untouched.
|
|
581
626
|
recorded = set(baseline.get("branches", []))
|
|
582
|
-
known =
|
|
627
|
+
known, used_v1 = _known(keys, recorded)
|
|
583
628
|
new = [k for k in keys if k not in known]
|
|
629
|
+
if used_v1:
|
|
630
|
+
# #2102: accepted, but never silently — a v1 entry cannot tell two
|
|
631
|
+
# same-labeled branches in one file apart, so the ratchet is weaker
|
|
632
|
+
# until the baseline is regenerated.
|
|
633
|
+
print(
|
|
634
|
+
"::warning::error-branch coverage: baseline holds v1 keys "
|
|
635
|
+
"(path:kind:label) — accepted for now, but same-labeled branches "
|
|
636
|
+
"in one file are indistinguishable until it is migrated. "
|
|
637
|
+
"Run: python scripts/error_branch_coverage.py --write "
|
|
638
|
+
"(after a coverage run) and commit the baseline.",
|
|
639
|
+
file=sys.stderr,
|
|
640
|
+
)
|
|
584
641
|
|
|
585
642
|
print(
|
|
586
643
|
f"unexecuted error branches: {len(keys)} "
|