From 4a72cc4fa665885fecbb90e58d651ce3a2f30689 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Tue, 22 Apr 2025 17:53:36 +0200 Subject: [PATCH] [ci] Fix escaping for gen_versions_map.sh script (#842) Backport of #842 to release-v0.30 second attept of https://github.com/cozystack/cozystack/pull/836 - Improved reliability of version generation by handling empty or special values safely in the process. (cherry picked from commit e505857832b5ab38a977cff6a3804632a2a56e6a) Signed-off-by: Nick Volynkin --- 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 c325cff3..27664229 100755 --- a/hack/gen_versions_map.sh +++ b/hack/gen_versions_map.sh @@ -24,14 +24,14 @@ search_commits=$(git ls-remote --tags origin | awk -F/ '$3 ~ /v[0-9]+.[0-9]+.[0- resolved_miss_map=$( echo "$miss_map" | while read -r chart version commit; do # if version is found in HEAD, it's HEAD - if [ $(awk '$1 == "version:" {print $2}' ./${chart}/Chart.yaml) = "${version}" ]; 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 [ "x$commit" != "xHEAD" ]; then - if [ $(git show "${commit}:./${chart}/Chart.yaml" 2>/dev/null | awk '$1 == "version:" {print $2}') != "${version}" ]; then + if [ "$commit" != "HEAD" ]; 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 | awk '$1 == "version:" {print $2}') = "${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