diff options
| -rw-r--r-- | CLAUDE.md | 5 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rwxr-xr-x | mkhint | 44 | ||||
| -rw-r--r-- | mkhint.bash-completion | 4 | ||||
| -rwxr-xr-x | tests/mkhint_test.sh | 25 |
5 files changed, 68 insertions, 12 deletions
@@ -41,6 +41,7 @@ No build step. Direct execution: ```bash bash mkhint --help bash mkhint --list # highlight hints whose version matches SBo .info +bash mkhint --list mypackage # side-by-side hint vs .info (no table) bash mkhint --review # review matched hints: diff + [K]eep/[D]elete/[S]kip bash mkhint --list --review # show highlighted table, then review bash mkhint --version 2.0.1 --hintfile mypackage @@ -120,6 +121,8 @@ Test coverage: | T55 | missing phantom-deps file — `--fix-current` and `--new` are no-ops | | T56 | `--fix-current` with `-v` — mutually-exclusive error, exit 1 | | T57 | `-l` skips hints with no `VERSION`; count excludes them | +| T58 | `-l <pkg>` shows side-by-side hint vs `.info`, not the table | +| T59 | `-l <missing>` — exit 2 | When adding new features, add a corresponding test case to `tests/mkhint_test.sh`. @@ -129,7 +132,7 @@ When adding new features, add a corresponding test case to `tests/mkhint_test.sh - `--new` with existing `.info`: copies `.info` as template, strips `PRGNAM`, `HOMEPAGE`, `MAINTAINER`, `EMAIL`, comments out `REQUIRES`, sets `ARCH="x86_64"`. Keeps `VERSION` from `.info`. If `-v` given, updates version string and recalculates checksums. Also appends an nvchecker `[section]` to the config, auto-detecting github/pypi source or providing a commented stub. - `--new` when hint already exists: backs up old, creates empty skeleton. - `--hintfile` with no `-v`: queries nvchecker for latest version, shows current vs. latest, prompts to accept/override/decline. After accepting, runs `nvtake` to sync nvchecker's keyfile. -- `--list` / `-l`: lists hints with `HintVer`/`SBOVer`; hints with no `VERSION` are skipped (and excluded from the total). Version columns are 22 wide to fit long version strings. Rows where the two are byte-equal are highlighted (color only on a TTY; plain when piped). Adds a legend when any row matched. +- `--list` / `-l`: lists hints with `HintVer`/`SBOVer`; hints with no `VERSION` are skipped (and excluded from the total). Version columns are 22 wide to fit long version strings. Rows where the two are byte-equal are highlighted (color only on a TTY; plain when piped). Adds a legend when any row matched. With package names (`-l foo bar`), the table is skipped and each named hint is shown side by side with its `.info` via `_show_hint_diff` (shared with `--review`); missing hint → exit 2. - `--review` / `-R`: with no package args, iterates only the matched (highlighted) hints. With explicit package names (`-R foo bar`), reviews each named hint regardless of version match (existence required: missing hint → exit 2). For each, shows the hint side-by-side with its `.info` (`git diff --no-index` if git present, else `diff -y`), then prompts `[K]eep / [D]elete / [S]kip` (default Keep). Delete removes the hint and its `.bak` via `_remove_hint`. Prints a deleted/kept summary counting hints actually reviewed. `-l` and `-R` combine: `-lR` shows the table first, then reviews. Bare `-R` with no matches → "nothing to review", exit 0. Per-hint logic lives in `_review_one_hint`; `review_hint_files` drives it from either the named list or `MATCHED_PKGS`. - `--check` / `-C`: runs nvchecker for all (or named) hints. With exactly one explicit package it uses `nvchecker -e <pkg>` to skip scanning the whole config; with two+ packages or no args it does one full scan. (`--hintfile` with no `-v` also queries via `nvchecker -e <pkg>`.) reports outdated packages with current → latest versions, prompts per-package to update, applies updates with `nvtake`, then prompts single `slackrepo update` for all updated packages. Hints with no `[pkg]` section in `nvchecker.toml` are collected and, after the scan, a single prompt offers to populate the config via `add_nvchecker_section` (github/pypi autodetect, else stub); on accept it prints a "review and re-run" message and stops the run without applying updates. Packages whose `.info` is not found in `REPO_DIR` are skipped. Upstream versions are normalized via `_normalize_version` (`-` → `_`) before comparing and before storing, so a dashed upstream version like `2026-06-02` matches the packaged `2026_06_02` (SlackBuild versions cannot contain `-`) and updates are written in the underscore form. The same normalization applies to `--hintfile` with no `-v`. `nvtake` still uses nvchecker's own raw keyfile value. - `--no-dl` / `-N`: downloads and recalculates checksums as normal, then appends `NODOWNLOAD=yes` after `MD5SUM_x86_64=`. Works with `--hintfile` or `--new`. Error if used alone. @@ -105,6 +105,8 @@ When updating a hint with multiline DOWNLOAD, mkhint: Lists each hint file with its `HintVer` (version in the hint) and `SBOVer` (version in the repository `.info`). Hints with no `VERSION` set (e.g. pure `DELREQUIRES` hints) are skipped. Version columns are wide enough for long version strings. Rows where the two are byte-equal are highlighted, so you can see at a glance which hints are now redundant with the upstream SBo version. Color is used only on a TTY; piped output is plain. A legend is printed when any row matched. +With one or more package names (`-l foo bar`), the table is skipped; instead each named hint is shown side by side with its `.info` (`git diff --no-index` if git is available, otherwise `diff -y`). A missing hint exits 2. + ```bash mkhint --list mkhint -l @@ -38,6 +38,7 @@ NEW_HINT_FILE="" DELETE_HINT_FILES=() MATCHED_PKGS=() REVIEW_PKGS=() +LIST_PKGS=() SHOW_LIST="" RUN_REVIEW="" COMMAND="" @@ -67,7 +68,7 @@ Options: --version, -v VERSION New version string (required for --hintfile) --hintfile, -f FILE Path to existing hint file (required with --version) --new, -n FILE Create new hint file (required with --version or standalone) - --list, -l List all hint files in the default directory + --list, -l [FILE...] List all hint files; FILE... = side-by-side hint vs .info --review, -R [FILE...] Review hints; no args = matched only, FILE... = named hints (any version) --clean, -c Remove all .bak files from HINT_DIR --check, -C [FILE...] Check hints for upstream updates via nvchecker, update interactively @@ -156,22 +157,31 @@ list_hint_files() { fi } -# Diff one hint against its .info and prompt Keep/Delete/Skip. -# Human-facing output goes to stderr; echoes only "deleted" or "kept" on stdout -# so the caller can capture the result. -_review_one_hint() { +# Show hint side-by-side with its .info. Output to the given fd (default 1). +_show_hint_diff() { local pkg="$1" + local fd="${2:-1}" local hint="${HINT_DIR%/}/${pkg}.hint" local info info=$(find "$REPO_DIR" -mindepth 2 -name "${pkg}.info" 2>/dev/null | head -1) - echo "" >&2 - echo "=== $pkg ===" >&2 + echo "" >&"$fd" + echo "=== $pkg ===" >&"$fd" if command -v git &>/dev/null; then - git diff --no-index --color=auto "$hint" "$info" >&2 || true + git diff --no-index --color=auto "$hint" "$info" >&"$fd" || true else - diff -y --width="${COLUMNS:-160}" "$hint" "$info" >&2 || true + diff -y --width="${COLUMNS:-160}" "$hint" "$info" >&"$fd" || true fi +} + +# Diff one hint against its .info and prompt Keep/Delete/Skip. +# Human-facing output goes to stderr; echoes only "deleted" or "kept" on stdout +# so the caller can capture the result. +_review_one_hint() { + local pkg="$1" + local hint="${HINT_DIR%/}/${pkg}.hint" + + _show_hint_diff "$pkg" 2 local ans read -r -p "Review $pkg: [K]eep / [D]elete / [S]kip (default Keep): " ans @@ -1042,6 +1052,8 @@ main() { while [[ $# -gt 0 ]]; do if [[ -n "$RUN_REVIEW" && -z "$COMMAND" ]]; then REVIEW_PKGS+=("$1") + elif [[ -n "$SHOW_LIST" && -z "$COMMAND" ]]; then + LIST_PKGS+=("$1") else DELETE_HINT_FILES+=("$1") fi @@ -1074,6 +1086,20 @@ main() { exit 1 fi + if [[ -n "$SHOW_LIST" && ${#LIST_PKGS[@]} -gt 0 ]]; then + local p + for p in "${LIST_PKGS[@]}"; do + if [[ ! -f "${HINT_DIR%/}/${p}.hint" ]]; then + echo "Error: hint file not found: ${HINT_DIR%/}/${p}.hint" >&2 + exit 2 + fi + done + for p in "${LIST_PKGS[@]}"; do + _show_hint_diff "$p" + done + exit 0 + fi + if [[ -n "$SHOW_LIST" || -n "$RUN_REVIEW" ]]; then [[ -n "$SHOW_LIST" ]] && list_hint_files if [[ -n "$RUN_REVIEW" ]]; then diff --git a/mkhint.bash-completion b/mkhint.bash-completion index 6d05ea3..1a72da2 100644 --- a/mkhint.bash-completion +++ b/mkhint.bash-completion @@ -10,10 +10,10 @@ _mkhintfile_completions() { local all_flags="--version -v --hintfile -f --new -n --list -l --review -R --clean -c --check -C --fix-current -F --delete -d --no-dl -N --help -h" - # -R/--review takes any number of hint names; complete them repeatedly. + # -R/--review and -l/--list take any number of hint names; complete them repeatedly. local w in_review="" for w in "${COMP_WORDS[@]:1}"; do - [[ "$w" == "-R" || "$w" == "--review" ]] && in_review=1 + [[ "$w" == "-R" || "$w" == "--review" || "$w" == "-l" || "$w" == "--list" ]] && in_review=1 done if [[ -n "$in_review" && "$cur" != -* ]]; then local -a rwords=() diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh index 425eba2..974441c 100755 --- a/tests/mkhint_test.sh +++ b/tests/mkhint_test.sh @@ -1122,6 +1122,31 @@ echo "$out" | grep -q "Total: 1 file" \ && { echo " PASS: count excludes versionless"; (( PASS++ )); } \ || { echo " FAIL: count wrong"; (( FAIL++ )); ERRORS+=("T57 count"); } +# ── T58: -l <pkg> shows side-by-side diff, not the table ───────────────────── +echo "" +echo "T58: -l <pkg> shows hint vs .info diff" +rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null +cat > "$MOCK_HINT/curl.hint" << 'EOF' +VERSION="8.5.0" +ARCH="x86_64" +EOF +out=$(run_mkhint -l curl 2>&1) +echo "$out" | grep -q "=== curl ===" \ + && { echo " PASS: diff header shown"; (( PASS++ )); } \ + || { echo " FAIL: diff header missing"; (( FAIL++ )); ERRORS+=("T58 header"); } +echo "$out" | grep -q "HintVer" \ + && { echo " FAIL: table printed"; (( FAIL++ )); ERRORS+=("T58 table"); } \ + || { echo " PASS: no table"; (( PASS++ )); } + +# ── T59: -l <missing> → exit 2 ─────────────────────────────────────────────── +echo "" +echo "T59: -l on nonexistent hint → exit 2" +set +e +run_mkhint -l nope 2>/dev/null +code=$? +set -e +assert_exit_code "missing hint" 2 "$code" + # ─── SUMMARY ────────────────────────────────────────────────────────────────── teardown |
