From 559eb8dea96876f6fb4ff78ceeb803a71122a2c8 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Wed, 9 Apr 2025 18:49:39 +0200 Subject: [PATCH] Fix: versions_map, use awk instead of grep Signed-off-by: Andrei Kvapil --- hack/gen_versions_map.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hack/gen_versions_map.sh b/hack/gen_versions_map.sh index a7e86ee9..3b65bb4f 100755 --- a/hack/gen_versions_map.sh +++ b/hack/gen_versions_map.sh @@ -19,19 +19,19 @@ fi miss_map=$(echo "$new_map" | awk 'NR==FNR { nm[$1 " " $2] = $3; next } { if (!($1 " " $2 in nm)) print $1, $2, $3}' - "$file") # search accross all tags sorted by version -search_commits=$(git ls-remote --tags origin | grep 'refs/tags/v' | sort -k2,2 -rV | awk '{print $1}') +search_commits=$(git ls-remote --tags origin | awk -F/ '$3 ~ /v[0-9]+.[0-9]+.[0-9]+/ {print}' | sort -k2,2 -rV | awk '{print $1}') resolved_miss_map=$( echo "$miss_map" | while read -r chart version commit; do # if version is found in HEAD, it's HEAD - if grep -q "^version: $version$" ./${chart}/Chart.yaml; then + if [ $(awk '$1 == "version:" {print $2}' ./${chart}/Chart.yaml) = "${version}" ]; then echo "$chart $version HEAD" continue fi # if commit is not HEAD, check if it's valid if [ $commit != "HEAD" ]; then - if ! git show "${commit}:./${chart}/Chart.yaml" 2>/dev/null | grep -q "^version: $version$"; then + if [ $(git show "${commit}:./${chart}/Chart.yaml" 2>/dev/null | awk '$1 == "version:" {print $2}') != "${version}" ]; then echo "Commit $commit for $chart $version is not valid" >&2 exit 1 fi @@ -44,7 +44,7 @@ resolved_miss_map=$( # if commit is HEAD, but version is not found in HEAD, check all tags found_tag="" for tag in $search_commits; do - if git show "${tag}:./${chart}/Chart.yaml" 2>/dev/null | grep -q "^version: $version$"; then + if [ $(git show "${tag}:./${chart}/Chart.yaml" 2>/dev/null | awk '$1 == "version:" {print $2}') = "${version}" ]; then found_tag=$(git rev-parse --short "${tag}") break fi