diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-09 19:09:17 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-09 19:09:17 +0200 |
| commit | 63fe4c87855ef0be12c624fee9febd67f04aa98f (patch) | |
| tree | da7fc855139282d060ddf230138069b26b94f1a0 | |
| parent | 126dea4d315a5bd6354deb6e485a1624df7ad702 (diff) | |
| download | mkhintfile-63fe4c87855ef0be12c624fee9febd67f04aa98f.tar.gz mkhintfile-63fe4c87855ef0be12c624fee9febd67f04aa98f.zip | |
refactor: 3-field bundle manifest (pkg mode rest); url mode explicit
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| -rwxr-xr-x | mkhint | 32 | ||||
| -rwxr-xr-x | tests/mkhint_test.sh | 25 |
2 files changed, 41 insertions, 16 deletions
@@ -536,32 +536,40 @@ match_dep_url() { return 1 } -# Loaded map: pkg name -> URL template. Populated by load_bundle_manifests. -declare -A BUNDLE_MANIFESTS=() +# Loaded maps: pkg -> mode ("url"|"sha"); pkg -> mode-specific remainder. +# url: remainder = the {VERSION} manifest URL template. +# sha: remainder = "<repo> <version-template> <name=path> <name=path>...". +declare -A BUNDLE_MODE=() +declare -A BUNDLE_REST=() load_bundle_manifests() { - BUNDLE_MANIFESTS=() + BUNDLE_MODE=(); BUNDLE_REST=() [[ -f "$BUNDLE_MANIFEST_FILE" ]] || return 0 - local line pkg url + local line pkg mode rest while IFS= read -r line; do line="${line%%#*}" [[ -z "${line// }" ]] && continue - read -r pkg url <<< "$line" - [[ -n "$pkg" && -n "$url" ]] && BUNDLE_MANIFESTS["$pkg"]="$url" + read -r pkg mode rest <<< "$line" + [[ -n "$pkg" && -n "$mode" && -n "$rest" ]] || continue + BUNDLE_MODE["$pkg"]="$mode" + BUNDLE_REST["$pkg"]="$rest" done < "$BUNDLE_MANIFEST_FILE" } -# manifest_url_for <pkg> <version> — echo the manifest URL for pkg with -# {VERSION} substituted. Non-zero if pkg is not listed. +# bundle_mode <pkg> — echo the mode for pkg, empty if not listed. +bundle_mode() { printf '%s\n' "${BUNDLE_MODE[$1]:-}"; } + +# manifest_url_for <pkg> <version> — echo the url-mode manifest URL for pkg with +# {VERSION} substituted. Non-zero if pkg is not a url-mode entry. manifest_url_for() { local pkg="$1" ver="$2" - local tmpl="${BUNDLE_MANIFESTS[$pkg]:-}" - [[ -z "$tmpl" ]] && return 1 + [[ "${BUNDLE_MODE[$pkg]:-}" == "url" ]] || return 1 + local tmpl="${BUNDLE_REST[$pkg]}" printf '%s\n' "${tmpl//\{VERSION\}/$ver}" } -# True if pkg has a bundle manifest configured. +# True if pkg has any bundle manifest configured (either mode). pkg_has_manifest() { - [[ -n "${BUNDLE_MANIFESTS[$1]:-}" ]] + [[ -n "${BUNDLE_MODE[$1]:-}" ]] } # fetch_manifest <url> — download the manifest to a temp file, echo its path. diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh index a7d1537..4843afd 100755 --- a/tests/mkhint_test.sh +++ b/tests/mkhint_test.sh @@ -1611,7 +1611,7 @@ echo "" echo "T-BM6: manifest_url_for substitutes {VERSION}, unlisted pkg → non-zero" cat > "$MOCK_BASE/bundle-manifests" << 'EOF' # comment -neovim https://example.com/neovim/v{VERSION}/deps.txt +neovim url https://example.com/neovim/v{VERSION}/deps.txt EOF BM_SRC='source <(sed -n "/# ── bundled-dep manifest handling/,/# ── end bundled-dep/p" '"$SCRIPT"')' r=$(bash -c "BUNDLE_MANIFEST_FILE='$MOCK_BASE/bundle-manifests'; $BM_SRC; load_bundle_manifests; manifest_url_for neovim 0.13.0") @@ -1756,7 +1756,7 @@ r=$(bash -c "$BM_SRC; match_dep_url 'https://github.com/JuliaStrings/utf8proc/ar echo "" echo "T-BM10: --new listed pkg → manifest report, hint not rewritten by manifest" cat > "$MOCK_BASE/bundle-manifests" << 'EOF' -bmnvim https://example.com/bmnvim/v{VERSION}/deps.txt +bmnvim url https://example.com/bmnvim/v{VERSION}/deps.txt EOF cat > "$MOCK_BASE/manifest_fixture" << 'EOF' NVIM_URL https://github.com/neovim/neovim/archive/v0.13.0.tar.gz @@ -1782,6 +1782,23 @@ echo "$out" | grep -qi 'manifest' \ || { echo " PASS: no manifest code for non-listed"; (( PASS++ )); } rm -f "$MOCK_BASE/manifest_fixture" "$MOCK_BASE/bundle-manifests" +# ── T-BM-MODE: existing url-mode reconcile still works after 3-field migration ─ +echo "" +echo "T-BM-MODE: url-mode reconcile still runs after 3-field manifest migration" +cat > "$MOCK_BASE/bundle-manifests" << 'EOF' +bmnvim url https://raw.githubusercontent.com/neovim/neovim/{VERSION}/deps.txt +EOF +cat > "$MOCK_BASE/manifest_fixture" << 'EOF' +UTF8PROC_URL https://github.com/juliastrings/utf8proc/archive/v2.9.0.tar.gz +UTF8PROC_SHA256 a +EOF +rm -f "$MOCK_HINT/bmnvim.hint" +out=$(run_mkhint -n bmnvim 2>&1) +echo "$out" | grep -q 'bmnvim: bundled-dep manifest check' \ + && { echo " PASS: url-mode reconcile ran"; (( PASS++ )); } \ + || { echo " FAIL: url-mode reconcile did not run. out=$out"; (( FAIL++ )) || true; ERRORS+=("T-BM-MODE"); } +rm -f "$MOCK_BASE/manifest_fixture" "$MOCK_BASE/bundle-manifests" "$MOCK_HINT/bmnvim.hint" + # ── T-BM12: --force with --hintfile → exit 1 ───────────────────────────────── echo "" echo "T-BM12: --force is --check-only (errors with --hintfile/--new/--fix-current)" @@ -1801,7 +1818,7 @@ set -e # ── T-BM13..16: --check Phase 2 bundled-dep reconcile for listed packages ──── setup_bmnvim_check() { cat > "$MOCK_BASE/bundle-manifests" << 'EOF' -bmnvim https://example.com/bmnvim/v{VERSION}/deps.txt +bmnvim url https://example.com/bmnvim/v{VERSION}/deps.txt EOF cat > "$MOCK_BASE/manifest_fixture" << 'EOF' NVIM_URL https://github.com/neovim/neovim/archive/v0.13.0.tar.gz @@ -1913,7 +1930,7 @@ rm -f "$MOCK_BASE/manifest_fixture" "$MOCK_BASE/bundle-manifests" "$MOCK_HINT/bm echo "" echo "T-BM18: -f listed pkg -V bumps primary AND reconciles bundled deps" cat > "$MOCK_BASE/bundle-manifests" << 'EOF' -bmnvim https://example.com/bmnvim/v{VERSION}/deps.txt +bmnvim url https://example.com/bmnvim/v{VERSION}/deps.txt EOF cat > "$MOCK_BASE/manifest_fixture" << 'EOF' NVIM_URL https://github.com/neovim/neovim/archive/v0.14.0.tar.gz |
