Skip to content

Commit

Permalink
Don't suppress ignore for specific case of unique packages in nix
Browse files Browse the repository at this point in the history
Nix has changed snapshot scheme from YYYY-MM-DD to 0-unstable-YYYY-MM-DD,
so when ignored statuses are suppressed for projects which are only
packaged in nix, older version outdate newever versions because of
changed schema. Disallow ignored suppression in that specific case.

Fixes repology/repology-rules#823
  • Loading branch information
AMDmi3 committed Jun 11, 2024
1 parent 99066e6 commit 719abd7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions repology/classifier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ def _is_packageset_unique(packages: Sequence[Package]) -> bool:
return True


def _is_nix_mixed_snapshot_schemes_case(packages: Sequence[Package]) -> bool:
# hack/special case: nix has changed snapshot scheme from YYYY-MM-DD to
# 0-unstable-YYYY-MM-DD since the former compares as greater, we can't
# suppress ignore for nix, as it would make older snapshots outdated
# newer ones
has_old_scheme = False
has_new_scheme = False
if packages[0].family == 'nix':
for package in packages:
if package.version.startswith('20'):
has_old_scheme = True
elif package.version.startswith('0-unstable-'):
has_new_scheme = True

return has_old_scheme and has_new_scheme


def _should_suppress_ignore(packages: Sequence[Package]) -> bool:
if len(packages) <= 1:
return True
Expand All @@ -160,6 +177,9 @@ def _should_suppress_ignore(packages: Sequence[Package]) -> bool:
if package.has_flag(PackageFlags.NOSCHEME):
return False

if _is_nix_mixed_snapshot_schemes_case(packages):
return False

return True


Expand Down

0 comments on commit 719abd7

Please sign in to comment.