Skip to content

Commit 91f6883

Browse files
committed
Remove unnecessary jq validation of rust-version
`cargo metadata` already validates the version, checking that it's a string satisfying one of a small number of recognized formats. So the only validation `jq` needs to do is to make sure it is really only appending `.0` to the end if it is of the form `X.Y` for nonempty numeric `X` and `Y` (with no other characters anywhere). This shortens the `jq` query considerably, removing the unnecessary validation and also using regular expression replacement to replace the empty string that follows the a *full* `X.Y` line with `.0`.
1 parent efeb6e6 commit 91f6883

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

justfile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,7 @@ check-size:
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: (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-
''')
245+
msrv: (get-metadata '.packages[] | select(.name == "gix") | .rust_version | sub("^\\d+\\.\\d+\\K$"; ".0")')
255246

256247
# Regenerate the MSRV badge SVG
257248
msrv-badge:

0 commit comments

Comments
 (0)