Sort by string length for tags

This commit is contained in:
Shiming Zhang 2022-01-19 14:24:29 +08:00
parent c02916194f
commit 4dc93d65a4
1 changed files with 4 additions and 1 deletions

View File

@ -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}")