Skip to content

Commit d2f66a7

Browse files
committed
Fix: versions_map, use awk instead of grep
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 4b57529 commit d2f66a7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎hack/gen_versions_map.sh‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ fi
1919
miss_map=$(echo "$new_map" | awk 'NR==FNR { nm[$1 " " $2] = $3; next } { if (!($1 " " $2 in nm)) print $1, $2, $3}' - "$file")
2020

2121
# search accross all tags sorted by version
22-
search_commits=$(git ls-remote --tags origin | grep 'refs/tags/v' | sort -k2,2 -rV | awk '{print $1}')
22+
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}')
2323
# add latest main commit to search
2424
search_commits="${search_commits} $(git rev-parse "origin/main")"
2525

2626
resolved_miss_map=$(
2727
echo "$miss_map" | while read -r chart version commit; do
2828
# if version is found in HEAD, it's HEAD
29-
if grep -q "^version: $version$" ./${chart}/Chart.yaml; then
29+
if [ $(awk '$1 == "version:" {print $2}' ./${chart}/Chart.yaml) = "${version}" ]; then
3030
echo "$chart $version HEAD"
3131
continue
3232
fi
3333
3434
# if commit is not HEAD, check if it's valid
3535
if [ $commit != "HEAD" ]; then
36-
if ! git show "${commit}:./${chart}/Chart.yaml" 2>/dev/null | grep -q "^version: $version$"; then
36+
if [ $(git show "${commit}:./${chart}/Chart.yaml" 2>/dev/null | awk '$1 == "version:" {print $2}') != "${version}" ]; then
3737
echo "Commit $commit for $chart $version is not valid" >&2
3838
exit 1
3939
fi
@@ -46,7 +46,7 @@ resolved_miss_map=$(
4646
# if commit is HEAD, but version is not found in HEAD, check all tags
4747
found_tag=""
4848
for tag in $search_commits; do
49-
if git show "${tag}:./${chart}/Chart.yaml" 2>/dev/null | grep -q "^version: $version$"; then
49+
if [ $(git show "${tag}:./${chart}/Chart.yaml" 2>/dev/null | awk '$1 == "version:" {print $2}') = "${version}" ]; then
5050
found_tag=$(git rev-parse --short "${tag}")
5151
break
5252
fi

0 commit comments

Comments
 (0)