Skip to content

Commit 84cd85e

Browse files
committed
Enhance versions_map generator logic
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent f4fba79 commit 84cd85e

3 files changed

Lines changed: 206 additions & 206 deletions

File tree

‎hack/gen_versions_map.sh‎

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/sh
22
set -e
3+
34
file=versions_map
5+
46
charts=$(find . -mindepth 2 -maxdepth 2 -name Chart.yaml | awk 'sub("/Chart.yaml", "")')
57

6-
# <chart> <version> <commit>
78
new_map=$(
89
for chart in $charts; do
9-
awk '/^name:/ {chart=$2} /^version:/ {version=$2} END{printf "%s %s %s\n", chart, version, "HEAD"}' $chart/Chart.yaml
10+
awk '/^name:/ {chart=$2} /^version:/ {version=$2} END{printf "%s %s %s\n", chart, version, "HEAD"}' "$chart/Chart.yaml"
1011
done
1112
)
1213

@@ -15,47 +16,48 @@ if [ ! -f "$file" ] || [ ! -s "$file" ]; then
1516
exit 0
1617
fi
1718

18-
miss_map=$(echo "$new_map" | awk 'NR==FNR { new_map[$1 " " $2] = $3; next } { if (!($1 " " $2 in new_map)) print $1, $2, $3}' - $file)
19+
miss_map=$(echo "$new_map" | awk 'NR==FNR { nm[$1 " " $2] = $3; next } { if (!($1 " " $2 in nm)) print $1, $2, $3}' - "$file")
20+
21+
# 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}')
23+
# add latest main commit to search
24+
search_commits="${search_commits} $(git rev-parse "origin/main")"
1925

2026
resolved_miss_map=$(
21-
echo "$miss_map" | while read chart version commit; do
22-
if [ "$commit" = HEAD ]; then
23-
line=$(awk '/^version:/ {print NR; exit}' "./$chart/Chart.yaml")
24-
change_commit=$(git --no-pager blame -L"$line",+1 -- "$chart/Chart.yaml" | awk '{print $1}')
25-
26-
if [ "$change_commit" = "00000000" ]; then
27-
# Not committed yet, use previous commit
28-
line=$(git show HEAD:"./$chart/Chart.yaml" | awk '/^version:/ {print NR; exit}')
29-
commit=$(git --no-pager blame -L"$line",+1 HEAD -- "$chart/Chart.yaml" | awk '{print $1}')
30-
if [ $(echo $commit | cut -c1) = "^" ]; then
31-
# Previous commit not exists
32-
commit=$(echo $commit | cut -c2-)
33-
fi
34-
else
35-
# Committed, but version_map wasn't updated
36-
line=$(git show HEAD:"./$chart/Chart.yaml" | awk '/^version:/ {print NR; exit}')
37-
change_commit=$(git --no-pager blame -L"$line",+1 HEAD -- "$chart/Chart.yaml" | awk '{print $1}')
38-
if [ $(echo $change_commit | cut -c1) = "^" ]; then
39-
# Previous commit not exists
40-
commit=$(echo $change_commit | cut -c2-)
41-
else
42-
commit=$(git describe --always "$change_commit~1")
43-
fi
27+
echo "$miss_map" | while read -r chart version commit; do
28+
# if version is found in HEAD, it's HEAD
29+
if grep -q "^version: $version$" ./${chart}/Chart.yaml; then
30+
echo "$chart $version HEAD"
31+
continue
32+
fi
33+
34+
# if commit is not HEAD, check if it's valid
35+
if [ $commit != "HEAD" ]; then
36+
if ! git show "${commit}:./${chart}/Chart.yaml" 2>/dev/null | grep -q "^version: $version$"; then
37+
echo "Commit $commit for $chart $version is not valid" >&2
38+
exit 1
4439
fi
4540
46-
# Check if the commit belongs to the main branch
47-
if ! git merge-base --is-ancestor "$commit" main; then
48-
# Find the closest parent commit that belongs to main
49-
commit_in_main=$(git log --pretty=format:"%h" main -- "$chart" | head -n 1)
50-
if [ -n "$commit_in_main" ]; then
51-
commit="$commit_in_main"
52-
else
53-
# No valid commit found in main branch for $chart, skipping..."
54-
continue
55-
fi
41+
commit=$(git rev-parse --short "$commit")
42+
echo "$chart $version $commit"
43+
continue
44+
fi
45+
46+
# if commit is HEAD, but version is not found in HEAD, check all tags
47+
found_tag=""
48+
for tag in $search_commits; do
49+
if git show "${tag}:./${chart}/Chart.yaml" 2>/dev/null | grep -q "^version: $version$"; then
50+
found_tag=$(git rev-parse --short "${tag}")
51+
break
5652
fi
53+
done
54+
55+
if [ -z "$found_tag" ]; then
56+
echo "Can't find $chart $version in any version tag or in the latest main commit" >&2
57+
exit 1
5758
fi
58-
echo "$chart $version $commit"
59+
60+
echo "$chart $version $found_tag"
5961
done
6062
)
6163

‎packages/apps/versions_map‎

Lines changed: 133 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,155 @@
11
bucket 0.1.0 HEAD
2-
clickhouse 0.1.0 ca79f72
3-
clickhouse 0.2.0 7cd7de73
4-
clickhouse 0.2.1 5ca8823
5-
clickhouse 0.3.0 b00621e
6-
clickhouse 0.4.0 320fc32
7-
clickhouse 0.5.0 2a4768a5
8-
clickhouse 0.6.0 18bbdb67
9-
clickhouse 0.6.1 b7375f73
10-
clickhouse 0.6.2 425ce77f
2+
clickhouse 0.1.0 f7eaab0a
3+
clickhouse 0.2.0 53f2365e
4+
clickhouse 0.2.1 dfbc210b
5+
clickhouse 0.3.0 6c5cf5bf
6+
clickhouse 0.4.0 b40e1b09
7+
clickhouse 0.5.0 0f312d5c
8+
clickhouse 0.6.0 1ec10165
9+
clickhouse 0.6.1 c62a83a7
10+
clickhouse 0.6.2 8267072d
1111
clickhouse 0.7.0 HEAD
12-
ferretdb 0.1.0 4ffa8615
13-
ferretdb 0.1.1 5ca8823
14-
ferretdb 0.2.0 adaf603
15-
ferretdb 0.3.0 aa2f553
16-
ferretdb 0.4.0 def2eb0f
17-
ferretdb 0.4.1 a9555210
18-
ferretdb 0.4.2 425ce77f
12+
ferretdb 0.1.0 e9716091
13+
ferretdb 0.1.1 91b0499a
14+
ferretdb 0.2.0 6c5cf5bf
15+
ferretdb 0.3.0 b8e33d19
16+
ferretdb 0.4.0 b40e1b09
17+
ferretdb 0.4.1 1ec10165
18+
ferretdb 0.4.2 8267072d
1919
ferretdb 0.5.0 HEAD
20-
http-cache 0.1.0 a956713
21-
http-cache 0.2.0 5ca8823
22-
http-cache 0.3.0 fab5940
23-
http-cache 0.3.1 fab5940b
20+
http-cache 0.1.0 263e47be
21+
http-cache 0.2.0 53f2365e
22+
http-cache 0.3.0 6c5cf5bf
23+
http-cache 0.3.1 0f312d5c
2424
http-cache 0.4.0 HEAD
25-
kafka 0.1.0 760f86d2
26-
kafka 0.2.0 a2cc83d
27-
kafka 0.2.1 3ac17018
28-
kafka 0.2.2 d0758692
29-
kafka 0.2.3 5ca8823
30-
kafka 0.3.0 c07c4bbd
31-
kafka 0.3.1 b7375f73
32-
kafka 0.3.2 b75aaf17
33-
kafka 0.3.3 425ce77f
34-
kafka 0.4.0 0e10f952
25+
kafka 0.1.0 f7eaab0a
26+
kafka 0.2.0 c0685f43
27+
kafka 0.2.1 dfbc210b
28+
kafka 0.2.2 e9716091
29+
kafka 0.2.3 91b0499a
30+
kafka 0.3.0 6c5cf5bf
31+
kafka 0.3.1 c62a83a7
32+
kafka 0.3.2 93c46161
33+
kafka 0.3.3 8267072d
34+
kafka 0.4.0 85ec09b8
3535
kafka 0.5.0 HEAD
36-
kubernetes 0.1.0 f642698
37-
kubernetes 0.2.0 7cd7de73
38-
kubernetes 0.3.0 7caccec1
39-
kubernetes 0.4.0 6cae6ce8
40-
kubernetes 0.5.0 6bd2d455
41-
kubernetes 0.6.0 4cbc8a2c
42-
kubernetes 0.7.0 ceefae03
36+
kubernetes 0.1.0 263e47be
37+
kubernetes 0.2.0 53f2365e
38+
kubernetes 0.3.0 007d414f
39+
kubernetes 0.4.0 d7cfa53c
40+
kubernetes 0.5.0 dfbc210b
41+
kubernetes 0.6.0 5bbc488e
42+
kubernetes 0.7.0 e9716091
4343
kubernetes 0.8.0 ac11056e
44-
kubernetes 0.8.1 e54608d8
45-
kubernetes 0.8.2 5ca8823
46-
kubernetes 0.9.0 9b6dd19
47-
kubernetes 0.10.0 ac5c38b
48-
kubernetes 0.11.0 4eaca42
49-
kubernetes 0.11.1 4f430a90
50-
kubernetes 0.12.0 74649f8
51-
kubernetes 0.12.1 28fca4e
52-
kubernetes 0.13.0 ced8e5b9
44+
kubernetes 0.8.1 366bcafc
45+
kubernetes 0.8.2 f81be075
46+
kubernetes 0.9.0 6c5cf5bf
47+
kubernetes 0.10.0 b8e33d19
48+
kubernetes 0.11.0 4b90bf5a
49+
kubernetes 0.11.1 5fb9cfe3
50+
kubernetes 0.12.0 bb985806
51+
kubernetes 0.12.1 28fca4ef
52+
kubernetes 0.13.0 1ec10165
5353
kubernetes 0.14.0 bfbde07c
54-
kubernetes 0.14.1 fde4bcfa
55-
kubernetes 0.15.0 cb7b8158
56-
kubernetes 0.15.1 43e593c7
57-
kubernetes 0.15.2 43e593c7
58-
kubernetes 0.16.0 3d03b227
54+
kubernetes 0.14.1 898374b5
55+
kubernetes 0.15.0 4e68e65c
56+
kubernetes 0.15.1 160e4e2a
57+
kubernetes 0.15.2 8267072d
58+
kubernetes 0.16.0 077045b0
5959
kubernetes 0.17.0 HEAD
60-
mysql 0.1.0 f642698
61-
mysql 0.2.0 8b975ff0
62-
mysql 0.3.0 5ca8823
63-
mysql 0.4.0 93018c4
64-
mysql 0.5.0 4b84798
65-
mysql 0.5.1 fab5940b
66-
mysql 0.5.2 d8a92aa3
67-
mysql 0.5.3 425ce77f
60+
mysql 0.1.0 263e47be
61+
mysql 0.2.0 c24a103f
62+
mysql 0.3.0 53f2365e
63+
mysql 0.4.0 6c5cf5bf
64+
mysql 0.5.0 b40e1b09
65+
mysql 0.5.1 0f312d5c
66+
mysql 0.5.2 1ec10165
67+
mysql 0.5.3 8267072d
6868
mysql 0.6.0 HEAD
69-
nats 0.1.0 5ca8823
70-
nats 0.2.0 c07c4bbd
69+
nats 0.1.0 e9716091
70+
nats 0.2.0 6c5cf5bf
7171
nats 0.3.0 78366f19
72-
nats 0.3.1 b7375f73
73-
nats 0.4.0 da1e705a
74-
nats 0.4.1 425ce77f
72+
nats 0.3.1 c62a83a7
73+
nats 0.4.0 898374b5
74+
nats 0.4.1 8267072d
7575
nats 0.5.0 HEAD
76-
postgres 0.1.0 f642698
77-
postgres 0.2.0 7cd7de73
78-
postgres 0.2.1 4a97e297
79-
postgres 0.3.0 995dea6f
80-
postgres 0.4.0 ec283c33
81-
postgres 0.4.1 5ca8823
82-
postgres 0.5.0 c07c4bbd
83-
postgres 0.6.0 2a4768a
84-
postgres 0.6.2 54fd61c
85-
postgres 0.7.0 dc9d8bb
86-
postgres 0.7.1 175a65f
87-
postgres 0.8.0 cb7b8158
88-
postgres 0.9.0 160e4e2a
76+
postgres 0.1.0 263e47be
77+
postgres 0.2.0 53f2365e
78+
postgres 0.2.1 d7cfa53c
79+
postgres 0.3.0 dfbc210b
80+
postgres 0.4.0 e9716091
81+
postgres 0.4.1 91b0499a
82+
postgres 0.5.0 6c5cf5bf
83+
postgres 0.6.0 b40e1b09
84+
postgres 0.6.2 0f312d5c
85+
postgres 0.7.0 4b90bf5a
86+
postgres 0.7.1 1ec10165
87+
postgres 0.8.0 4e68e65c
88+
postgres 0.9.0 8267072d
8989
postgres 0.10.0 HEAD
90-
rabbitmq 0.1.0 f642698
91-
rabbitmq 0.2.0 5ca8823
92-
rabbitmq 0.3.0 9e33dc0
93-
rabbitmq 0.4.0 36d8855
94-
rabbitmq 0.4.1 35536bb
95-
rabbitmq 0.4.2 00b2834e
96-
rabbitmq 0.4.3 d8a92aa3
97-
rabbitmq 0.4.4 425ce77f
90+
rabbitmq 0.1.0 263e47be
91+
rabbitmq 0.2.0 53f2365e
92+
rabbitmq 0.3.0 6c5cf5bf
93+
rabbitmq 0.4.0 b40e1b09
94+
rabbitmq 0.4.1 1128d0cb
95+
rabbitmq 0.4.2 4b90bf5a
96+
rabbitmq 0.4.3 1ec10165
97+
rabbitmq 0.4.4 8267072d
9898
rabbitmq 0.5.0 HEAD
99-
redis 0.1.1 f642698
100-
redis 0.2.0 5ca8823
101-
redis 0.3.0 c07c4bbd
102-
redis 0.3.1 b7375f73
103-
redis 0.4.0 abc8f082
104-
redis 0.5.0 0e728870
99+
redis 0.1.1 263e47be
100+
redis 0.2.0 53f2365e
101+
redis 0.3.0 6c5cf5bf
102+
redis 0.3.1 c62a83a7
103+
redis 0.4.0 84f3ccc0
104+
redis 0.5.0 4e68e65c
105105
redis 0.6.0 HEAD
106-
tcp-balancer 0.1.0 f642698
107-
tcp-balancer 0.2.0 a9567139
106+
tcp-balancer 0.1.0 263e47be
107+
tcp-balancer 0.2.0 53f2365e
108108
tcp-balancer 0.3.0 HEAD
109-
tenant 0.1.3 3d1b86c
110-
tenant 0.1.4 d200480
111-
tenant 0.1.5 e3ab858
112-
tenant 1.0.0 7cd7de7
113-
tenant 1.1.0 4da8ac3b
114-
tenant 1.2.0 15478a88
115-
tenant 1.3.0 ceefae03
116-
tenant 1.3.1 c56e5769
117-
tenant 1.4.0 94c688f7
118-
tenant 1.5.0 48128743
109+
tenant 0.1.4 afc997ef
110+
tenant 0.1.5 e3ab858a
111+
tenant 1.0.0 263e47be
112+
tenant 1.1.0 c0685f43
113+
tenant 1.2.0 dfbc210b
114+
tenant 1.3.0 e9716091
115+
tenant 1.3.1 91b0499a
116+
tenant 1.4.0 71514249
117+
tenant 1.5.0 1ec10165
119118
tenant 1.6.0 df448b99
120-
tenant 1.6.1 edbbb9be
121-
tenant 1.6.2 ccedc5fe
119+
tenant 1.6.1 c62a83a7
120+
tenant 1.6.2 898374b5
122121
tenant 1.6.3 2057bb96
123-
tenant 1.6.4 3c9e50a4
124-
tenant 1.6.5 f1e11451
125-
tenant 1.6.6 d4634797
126-
tenant 1.6.7 06afcf27
127-
tenant 1.6.8 4cc48e6f
128-
tenant 1.7.0 6c73e3f3
129-
tenant 1.8.0 e2369ba
130-
tenant 1.9.0 43e593c7
122+
tenant 1.6.4 84f3ccc0
123+
tenant 1.6.5 fde4bcfa
124+
tenant 1.6.6 4e68e65c
125+
tenant 1.6.7 0ab39f20
126+
tenant 1.6.8 bc95159a
127+
tenant 1.7.0 24fa7222
128+
tenant 1.8.0 160e4e2a
129+
tenant 1.9.0 728743db
131130
tenant 1.9.1 HEAD
132-
virtual-machine 0.1.4 f2015d6
133-
virtual-machine 0.1.5 7cd7de7
134-
virtual-machine 0.2.0 5ca8823
135-
virtual-machine 0.3.0 b908400
136-
virtual-machine 0.4.0 4746d51
137-
virtual-machine 0.5.0 cad9cde
138-
virtual-machine 0.6.0 0e728870
139-
virtual-machine 0.6.1 af58018a
140-
virtual-machine 0.7.0 af58018a
141-
virtual-machine 0.7.1 05857b95
142-
virtual-machine 0.8.0 3fa4dd3
143-
virtual-machine 0.8.1 3fa4dd3a
131+
virtual-machine 0.1.4 f2015d65
132+
virtual-machine 0.1.5 263e47be
133+
virtual-machine 0.2.0 c0685f43
134+
virtual-machine 0.3.0 6c5cf5bf
135+
virtual-machine 0.4.0 b8e33d19
136+
virtual-machine 0.5.0 1ec10165
137+
virtual-machine 0.6.0 4e68e65c
138+
virtual-machine 0.7.0 e23286a3
139+
virtual-machine 0.7.1 0ab39f20
140+
virtual-machine 0.8.0 3fa4dd3a
141+
virtual-machine 0.8.1 93c46161
144142
virtual-machine 0.8.2 HEAD
145143
vm-disk 0.1.0 HEAD
146-
vm-instance 0.1.0 ced8e5b9
147-
vm-instance 0.2.0 4f767ee3
148-
vm-instance 0.3.0 0e728870
149-
vm-instance 0.4.0 af58018a
150-
vm-instance 0.4.1 05857b95
151-
vm-instance 0.5.0 3fa4dd3
144+
vm-instance 0.1.0 1ec10165
145+
vm-instance 0.2.0 84f3ccc0
146+
vm-instance 0.3.0 4e68e65c
147+
vm-instance 0.4.0 e23286a3
148+
vm-instance 0.4.1 0ab39f20
149+
vm-instance 0.5.0 3fa4dd3a
152150
vm-instance 0.5.1 HEAD
153-
vpn 0.1.0 f642698
154-
vpn 0.2.0 7151424
155-
vpn 0.3.0 a2bcf100
156-
vpn 0.3.1 f7220f19
151+
vpn 0.1.0 263e47be
152+
vpn 0.2.0 53f2365e
153+
vpn 0.3.0 6c5cf5bf
154+
vpn 0.3.1 1ec10165
157155
vpn 0.4.0 HEAD

0 commit comments

Comments
 (0)