Skip to content

Commit 552c37b

Browse files
committed
fix(core): use grep-o to parse tag_name robustly from compact json
awk -F'"' with $4 fails when github api returns single-line json, misreading the url field as the version; grep -o matches tag_name regardless of whitespace or line format
1 parent 9b10491 commit 552c37b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

modules/core.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ lib.mkMerge [
167167
echo "mise upgrade: GitHub API returned HTTP $http_code, skipping" >&2
168168
exit 0 ;;
169169
esac
170-
latest=$(awk -F'"' '/"tag_name":/ { sub(/^v/, "", $4); print $4; exit }' "$tmpdir/release.json")
170+
latest=$(grep -o '"tag_name": *"v[^"]*"' "$tmpdir/release.json" | grep -o 'v[^"]*' | sed 's/^v//')
171171
if [ -z "''${latest:-}" ]; then
172172
echo "mise upgrade: failed to parse latest tag, skipping" >&2
173173
exit 0
@@ -253,7 +253,7 @@ lib.mkMerge [
253253
echo "topgrade upgrade: GitHub API returned HTTP $http_code, skipping" >&2
254254
exit 0 ;;
255255
esac
256-
latest=$(awk -F'"' '/"tag_name":/ { sub(/^v/, "", $4); print $4; exit }' "$tmpdir/release.json")
256+
latest=$(grep -o '"tag_name": *"v[^"]*"' "$tmpdir/release.json" | grep -o 'v[^"]*' | sed 's/^v//')
257257
if [ -z "''${latest:-}" ]; then
258258
echo "topgrade upgrade: failed to parse latest tag, skipping" >&2
259259
exit 0

0 commit comments

Comments
 (0)