fix(pr-gate): greptile — exclude npm pre-release tags from version resolver

Pre-release versions (e.g. 1.0.0-alpha.1, 2.2.0-rc.1) could otherwise win
the newest-by-publish-time selection if a stable release fell inside the
3-day buffer, switching the merge-blocking PR gate to an unstable Claude
Code CLI.
This commit is contained in:
mateo-berri 2026-05-19 01:58:23 +00:00
parent ec767b7e4c
commit be4d8ec972
No known key found for this signature in database
2 changed files with 27 additions and 0 deletions

View file

@ -127,6 +127,31 @@ def test_uses_custom_min_age():
assert out == "0.9.0"
def test_excludes_prerelease_versions():
"""Pre-release tags (1.0.0-alpha.1, 2.0.0-rc.1, etc.) must never win,
even if their publish timestamp is the newest eligible one."""
metadata = _metadata_with_times(
{
"2.1.119": _t("2026-04-21T10:00:00.000Z"), # stable, 4d old
"2.2.0-alpha.1": _t("2026-04-22T10:00:00.000Z"), # newer publish
"2.2.0-rc.1": _t("2026-04-22T11:00:00.000Z"), # newest publish
"3.0.0-beta": _t("2026-04-22T12:00:00.000Z"), # newest publish
}
)
assert resolve_pr_gate_version(metadata=metadata, as_of=NOW) == "2.1.119"
def test_raises_when_only_prereleases_are_eligible():
metadata = _metadata_with_times(
{
"2.2.0-alpha.1": _t("2026-04-22T10:00:00.000Z"),
"2.2.0-rc.1": _t("2026-04-22T11:00:00.000Z"),
}
)
with pytest.raises(NoEligibleVersionError):
resolve_pr_gate_version(metadata=metadata, as_of=NOW)
def test_resolver_uses_fetcher_when_metadata_not_provided():
captured = {}

View file

@ -111,6 +111,8 @@ def resolve_pr_gate_version(
continue
if not isinstance(raw_ts, str):
continue
if "-" in version:
continue
published = _parse_npm_timestamp(raw_ts)
if published <= cutoff:
eligible.append((published, version))