From 4dc93d65a4456ccd232af0d10c8f485f66de6929 Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Wed, 19 Jan 2022 14:24:29 +0800 Subject: [PATCH] Sort by string length for tags --- hack/diff-image.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hack/diff-image.sh b/hack/diff-image.sh index 6baf5a0..14e85ed 100755 --- a/hack/diff-image.sh +++ b/hack/diff-image.sh @@ -166,7 +166,10 @@ function copy-image() { function list-tags() { local image="${1:-}" - local raw="$(${SKOPEO} list-tags --retry-times "${RETRY}" --no-creds --tls-verify=false "docker://${image}" | ${JQ} -r '.Tags[]' | sort)" + local raw="$(${SKOPEO} list-tags --retry-times "${RETRY}" --no-creds --tls-verify=false "docker://${image}" | ${JQ} -r '.Tags[]')" + + # Sort by string length + raw=$(echo "${raw}" | awk '{print length, $0}' | sort -n | awk '{print $2}') if [[ "${FOCUS}" != "" ]]; then local skip=$(echo "${raw}" | grep -v -E "${FOCUS}")