feat(dry): extract sha256sum, create utils.lua, remove dead version.lua #331

Merged
fuzzy merged 2 commits from feat/dry-sha256sum-utils into main 2026-07-10 08:39:56 +00:00
Owner

What

Phase 5 DRY refactoring — extract duplicated patterns into shared functions, remove dead code.

Changes

sha256sum extraction (#0281/#0280)

  • hash.lua: Add hash.sha256sum(input_string) — hashes a string via sha256sum
  • cli.lua:88: Replace inline printf...sha256sum...cut with hasher.sha256sum(input)
  • build.lua:14: Replace pkg_hash's inline pipe with hash.sha256sum(str)

Shared utils (#0285/#0282-#0284)

  • lib/qpkg/utils.lua: New module with find_in_path(name)
  • pkgdef.lua: Remove local find_in_path, use utils.find_in_path
  • fetch.lua: find_program now delegates to utils.find_in_path

Remove dead code (#0287/#0286)

  • lib/qpkg/version.lua: Deleted (imported by zero modules, deprecated)
  • Version tests removed from test_qpkg_spec.lua

Testing

  • luacheck — 0 warnings, 0 errors
  • Old harness — 56/56 pass
  • busted — 76/76 pass (14 version tests removed with module)

Closes #281

## What Phase 5 DRY refactoring — extract duplicated patterns into shared functions, remove dead code. ## Changes ### sha256sum extraction (#0281/#0280) - `hash.lua`: Add `hash.sha256sum(input_string)` — hashes a string via sha256sum - `cli.lua:88`: Replace inline `printf...sha256sum...cut` with `hasher.sha256sum(input)` - `build.lua:14`: Replace `pkg_hash`'s inline pipe with `hash.sha256sum(str)` ### Shared utils (#0285/#0282-#0284) - `lib/qpkg/utils.lua`: New module with `find_in_path(name)` - `pkgdef.lua`: Remove local `find_in_path`, use `utils.find_in_path` - `fetch.lua`: `find_program` now delegates to `utils.find_in_path` ### Remove dead code (#0287/#0286) - `lib/qpkg/version.lua`: Deleted (imported by zero modules, deprecated) - Version tests removed from `test_qpkg_spec.lua` ## Testing - [x] luacheck — 0 warnings, 0 errors - [x] Old harness — 56/56 pass - [x] busted — 76/76 pass (14 version tests removed with module) Closes #281
Extract duplicated sha256sum shell-out:
- Add hash.sha256sum(input_string) to hash.lua
- Replace inline printf|sha256sum|cut in cli.lua:88 and build.lua:14

Create lib/qpkg/utils.lua with shared helpers:
- Move find_in_path from pkgdef.lua to utils.lua
- Update pkgdef.lua to use utils.find_in_path
- Update fetch.lua find_program to use utils.find_in_path

Remove dead version.lua:
- Deleted lib/qpkg/version.lua (imported by zero modules)
- Removed version tests from test_qpkg_spec.lua

Closes #281, #280, #285, #282, #283, #284, #287, #286
docs(roadmap): mark Phase 5 tasks completed
All checks were successful
PR Checks / lint-and-test (pull_request) Successful in 16m40s
e09ae9e561
the.auditor left a comment

Review — Approved

Clean DRY refactoring. Verified:

  • 76/76 tests pass
  • 0 luacheck warnings/errors
  • No remaining references to version.lua in codebase

All three changes are behavior-preserving. The fetch.lua switch from command -v to io.open is functionally equivalent for the tools being searched (wget, curl, fetch, ftp, luapp).

Non-blocking

  1. hash.sha256sum and utils.find_in_path lack direct unit tests (only indirect coverage through callers). Filed as #332.
## Review — Approved Clean DRY refactoring. Verified: - 76/76 tests pass - 0 luacheck warnings/errors - No remaining references to `version.lua` in codebase All three changes are behavior-preserving. The `fetch.lua` switch from `command -v` to `io.open` is functionally equivalent for the tools being searched (wget, curl, fetch, ftp, luapp). ## Non-blocking 1. `hash.sha256sum` and `utils.find_in_path` lack direct unit tests (only indirect coverage through callers). Filed as #332.
fuzzy merged commit e09ae9e561 into main 2026-07-10 08:39:56 +00:00
fuzzy deleted branch feat/dry-sha256sum-utils 2026-07-10 08:39:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/qpkg!331
No description provided.