Skip to content

Sort checksums.txt by filename in generate-checksums.sh#139

Merged
lex57ukr merged 3 commits into
mainfrom
138-sort-checksums-by-filename
May 25, 2026
Merged

Sort checksums.txt by filename in generate-checksums.sh#139
lex57ukr merged 3 commits into
mainfrom
138-sort-checksums-by-filename

Conversation

@lex57ukr
Copy link
Copy Markdown
Contributor

Summary

The checksums file produced by scripts/generate-checksums.sh was sorted by the leading sha256 prefix instead of by filename, since the trailing | sort compared lines starting at column 1. Output was deterministic but not human-useful and didn't match the apparent intent of the sort. Switch to LC_ALL=C sort -k2,2 so lines are ordered by filename with locale-independent byte semantics, and pin the intermediate filename sort to the same locale so the diagnostic output stays reproducible too.

Related Issues

Fixes #138

Changes

  • generate-checksums.sh: sort checksums.txt lines by the filename column (sort -k2,2) and pin both sort steps to LC_ALL=C for byte-identical output across environments.
  • tests/bats/scripts/generate-checksums.bats: convert the membership-only assertion to an order assertion (the previously-pinned quirk would now fail), and add a dedicated locale-independence test that runs the script with LC_ALL=en_US.UTF-8 in the caller's env and asserts C-order output — future refactors that drop the in-script LC_ALL=C fail here instead of slipping by on ASCII fixtures.

Further Comments

The ci-tools image generates en_US.UTF-8 precisely so tests can exercise locale invariants (see images/ci-tools/Dockerfile:35-39). This is the first test in the suite to actually use that capability.

lex57ukr added 3 commits May 25, 2026 07:51
The trailing `| sort` ordered lines by the leading sha256 prefix
(effectively random), not by filename. Output was deterministic
but not human-useful. Switch to `LC_ALL=C sort -k2,2` so lines are
sorted by the filename column with locale-independent byte order.

Tighten the bats coverage too: the membership-only assertion is
now an order-asserting check that would have caught the original
quirk.
The first sort orders the filename list before sha256sum and feeds
the "Release assets:" diagnostic print. Without LC_ALL=C it was
locale-dependent, so the same input could produce a different
diagnostic order on a different machine. The final checksums.txt
sort was already locale-pinned by the previous commit; matching
the intermediate sort removes the inconsistency.
The ci-tools image generates en_US.UTF-8 specifically so tests can
verify locale-independent behavior. Exercise that for the
checksums.txt sort: stage filenames where C-order ('A', 'C', 'b' —
byte order) and en_US.UTF-8-order ('A', 'b', 'C' — case-insensitive)
differ, invoke the script with LC_ALL=en_US.UTF-8 in the caller's
env, and assert C-order output. A future refactor that drops the
in-script LC_ALL=C now fails this test instead of slipping by on
ASCII-only fixtures.
@lex57ukr lex57ukr added the bug Something isn't working label May 25, 2026
@lex57ukr lex57ukr merged commit 41636e8 into main May 25, 2026
8 checks passed
@lex57ukr lex57ukr deleted the 138-sort-checksums-by-filename branch May 25, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sort checksums.txt by filename in generate-checksums.sh

1 participant