diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-08 11:25:38 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-08 11:25:38 +0200 |
| commit | efeeeb045ee8f7d92bc718c40661df0f5fb070c7 (patch) | |
| tree | 632e789f2d4ac01487c37f4bcdec2a9f41526efb /mkhint | |
| parent | 006043e71cf6ee40b69da2e129a095ff4661dfb5 (diff) | |
| download | mkhintfile-6f82b85f050b6c617201169bfcfb8720fa10eba4.tar.gz mkhintfile-6f82b85f050b6c617201169bfcfb8720fa10eba4.zip | |
fix: version-aware bundled-dep reconcile; release v1.2.1v1.2.1
reconcile_bundle_deps flagged a dep as changed on raw URL-string
inequality. Manifests serve bare-tag archive URLs
(.../archive/v0.26.7.tar.gz) while hints use the SBo-fetched tree shape
(.../archive/v0.26.7/tree-sitter-0.26.7.tar.gz) — same version, different
path — so every dep was reported changed at a version that had not moved.
Add _url_version to parse and normalize the version from a URL basename,
and detect change by version rather than URL string. Only rewrite a line
when the version actually differs. Change report now shows
"name old-ver -> new-ver". Regression test T-BM17 pins the same-version,
different-shape case as no change (180 passed).
Bump MKHINT_VERSION and man title to 1.2.1, rebuild mkhint.1.gz.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'mkhint')
| -rwxr-xr-x | mkhint | 43 |
1 files changed, 37 insertions, 6 deletions
@@ -45,7 +45,7 @@ if [[ ! -d $TMP_DIR ]]; then mkdir $TMP_DIR fi -readonly MKHINT_VERSION="1.2.0" +readonly MKHINT_VERSION="1.2.1" # Variables VERSION="" @@ -457,6 +457,29 @@ _url_stem() { printf '%s\n' "$base" } +# _url_version <url> — extract the version token from a download URL's basename. +# Same archive stripping as _url_stem, then take the trailing version: a +# leading-v-or-digit tail after a "-" separator, else the whole basename if it +# is itself a version (e.g. "v0.26.7"). Used to detect real version drift +# independent of URL path shape. Empty if no version found. +_url_version() { + local base="${1##*/}" + base="${base%.tar.gz}"; base="${base%.tar.xz}"; base="${base%.tar.bz2}" + base="${base%.zip}"; base="${base%.tgz}" + local ver="" + if [[ "$base" =~ -([vV]?[0-9][^/]*)$ ]]; then + ver="${BASH_REMATCH[1]}" + elif [[ "$base" =~ -([0-9a-f]{7,})$ ]]; then + ver="${BASH_REMATCH[1]}" + elif [[ "$base" =~ ^([vV]?[0-9][^/]*)$ ]]; then + ver="${BASH_REMATCH[1]}" + elif [[ "$base" =~ ^([0-9a-f]{7,})$ ]]; then + ver="${BASH_REMATCH[1]}" + fi + ver="${ver#[vV]}" + printf '%s\n' "$(_normalize_version "$ver")" +} + # _url_repo <url> — echo owner/repo for a github URL, empty otherwise. _url_repo() { [[ "$1" =~ github\.com/([^/]+)/([^/]+) ]] && printf '%s/%s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]%.git}" @@ -572,7 +595,8 @@ reconcile_bundle_deps() { # Track which manifest URLs got matched (for the FYI of unmatched ones). local -A matched_manifest=() local -a new_urls=("${urls[@]}") - local -a changed_idx=() changed_from=() changed_to=() + local -a changed_idx=() changed_to=() + local -a changed_name=() changed_oldver=() changed_newver=() local i m # The primary hint URL (index 0) is never reconciled, but its manifest @@ -587,9 +611,16 @@ reconcile_bundle_deps() { continue fi matched_manifest["$m"]=1 - if [[ "$m" != "${urls[$i]}" ]]; then - changed_idx+=("$i"); changed_from+=("${urls[$i]}"); changed_to+=("$m") - new_urls[$i]="$m" + # Detect real drift by version, not URL string: the manifest and the + # hint often carry the same version in different path shapes (bare-tag + # archive vs SBo-fetched tree). Only a version change is a change. + local hv mv + hv=$(_url_version "${urls[$i]}") + mv=$(_url_version "$m") + if [[ -n "$mv" && "$hv" != "$mv" ]]; then + changed_idx+=("$i"); changed_to+=("$m"); new_urls[$i]="$m" + changed_name+=("$(_dep_label "${urls[$i]}")") + changed_oldver+=("${hv:-?}"); changed_newver+=("$mv") fi done @@ -612,7 +643,7 @@ reconcile_bundle_deps() { echo "" echo "$pkg bundled deps changed upstream:" for (( i=0; i<${#changed_idx[@]}; i++ )); do - printf ' %s -> %s\n' "${changed_from[$i]##*/}" "${changed_to[$i]##*/}" + printf ' %s %s -> %s\n' "${changed_name[$i]}" "${changed_oldver[$i]}" "${changed_newver[$i]}" done return 0 fi |
