From d49362dc77dc3594d7be5f72d2860a136b81754f Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Wed, 16 Oct 2024 14:43:44 -0700 Subject: [PATCH] Use jq's `IN()` instead of `index()` The end result is the same, but the construction is more ergonomic. --- Dockerfile.template | 8 ++++---- versions.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile.template b/Dockerfile.template index 84b22db42..c5ceed1ca 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -63,7 +63,7 @@ RUN set -eux; \ {{ if is_alpine then ( -}} apk add --no-cache --virtual .ruby-builddeps \ autoconf \ -{{ if [ "3.1", "3.2" ] | index(env.version | rtrimstr("-rc")) then ( -}} +{{ if env.version | rtrimstr("-rc") | IN("3.1", "3.2") then ( -}} {{ # https://github.com/docker-library/ruby/pull/438 -}} bison \ {{ ) else "" end -}} @@ -87,7 +87,7 @@ RUN set -eux; \ openssl-dev \ patch \ procps \ -{{ if [ "3.1", "3.2" ] | index(env.version | rtrimstr("-rc")) then ( -}} +{{ if env.version | rtrimstr("-rc") | IN("3.1", "3.2") then ( -}} readline-dev \ {{ ) else "" end -}} ruby \ @@ -100,7 +100,7 @@ RUN set -eux; \ savedAptMark="$(apt-mark showmanual)"; \ apt-get update; \ apt-get install -y --no-install-recommends \ -{{ if [ "3.1", "3.2" ] | index(env.version | rtrimstr("-rc")) then ( -}} +{{ if env.version | rtrimstr("-rc") | IN("3.1", "3.2") then ( -}} {{ # https://github.com/docker-library/ruby/pull/438 -}} bison \ {{ ) else "" end -}} @@ -115,7 +115,7 @@ RUN set -eux; \ libgdbm-compat-dev \ libglib2.0-dev \ libncurses-dev \ -{{ if [ "3.1", "3.2" ] | index(env.version | rtrimstr("-rc")) then ( -}} +{{ if env.version | rtrimstr("-rc") | IN("3.1", "3.2") then ( -}} libreadline-dev \ {{ ) else "" end -}} libxml2-dev \ diff --git a/versions.sh b/versions.sh index d5e02efee..aa5e6bc11 100755 --- a/versions.sh +++ b/versions.sh @@ -100,13 +100,13 @@ for version in "${versions[@]}"; do *) # YJIT doc="$(jq <<<"$doc" -sc ' - .[1][].arches? |= if . then with_entries(select(.key as $arch | [ + .[1][].arches? |= if . then with_entries(select(.key | IN( # https://github.com/ruby/ruby/blob/v3_2_0/doc/yjit/yjit.md ("currently supported for macOS and Linux on x86-64 and arm64/aarch64 CPUs") # https://github.com/ruby/ruby/blob/v3_2_0/configure.ac#L3757-L3761 "amd64", "arm64v8", empty # trailing comma - ] | index($arch))) else empty end + ))) else empty end | add ' - rust.json)" ;;