History

Use `jq` to validate and format the `rust-version`

This is clearer than the inline shell script previously used, and also more robust.

Eliah Kagan committed 1 year ago

Commit efeb6e61 parent 654a8fa1 file · +10 −13Browse files

Unified · Split

justfile+10−13
@@ -242,19 +242,16 @@ check-size: · 241 unmodified lines
242242 etc/check-package-size.sh
243243
244244 # Report the Minimum Supported Rust Version (the `rust-version` of `gix`) in X.Y.Z form
245−msrv:
246− set -eu; \
247− query='.packages[] | select(.name == "gix") | .rust_version'; \
248− value="$({{ j }} get-metadata "$query")"; \
249− case "$value" in \
250− *.*.*) \
251− echo "$value" ;; \
252− *.*) \
253− echo "$value.0" ;; \
254− *) \
255− echo "No '.' in gix rust-version '$value'" >&2; \
256− exit 1 ;; \
257− esac
245+msrv: (get-metadata '''
246+ (.packages[] | select(.name == "gix") | .rust_version | tostring) as $v |
247+ if ($v | test("^[0-9]+\\.[0-9]+\\.[0-9]+$")) then
248+ $v
249+ elif ($v | test("^[0-9]+\\.[0-9]+$")) then
250+ $v + ".0"
251+ else
252+ error("Unrecognized rust-version format: " + $v)
253+ end
254+''')
258255
259256 # Regenerate the MSRV badge SVG
260257 msrv-badge: