Skip to content

Commit 50f04fb

Browse files
authored
Fix README tag pollution from update script (#573)
* fix: Improve README tag generation to reduce clutter - Modified update.sh to only show the latest and stable versions - Removed duplicate major.minor version tags - Changed from listing all versions to showing only the most relevant tags - Fixed jq query to properly detect stable version using index() instead of contains() This significantly reduces README pollution by showing only: - The latest experimental version with its tags - The current stable version with its tags - One entry per major.minor version for older releases (removed from this commit) Before: 60+ lines of tags with many duplicates After: 2 lines showing only latest and stable versions * fix: Address shellcheck warnings about subshell variable modifications - Changed from pipeline to process substitution to avoid SC2030/SC2031 warnings - Variables modified in the while loop are now properly preserved - This ensures readme_tags modifications are not lost in subshells
1 parent 15d31c9 commit 50f04fb

File tree

2 files changed

+61
-57
lines changed

2 files changed

+61
-57
lines changed

README.md

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,9 @@
66
[中文](./README_zh_CN.md)
77

88
<!-- start autogeneration tags -->
9-
* `2.0.58`, `latest`
10-
* `2.0.57`
11-
* `2`, `2.0`, `2.0.55`, `stable`, `stable-2.0.55`
12-
* `2.0.54`
13-
* `2.0.53`
14-
* `2.0.52`
15-
* `2.0.51`
16-
* `2.0.50`
17-
* `2.0.49`
18-
* `2.0.48`
19-
* `2.0`, `2.0.47`, `stable-2.0.47`
20-
* `2.0.46`
21-
* `2.0.45`
22-
* `2.0.44`
23-
* `2.0`, `2.0.43`, `stable-2.0.43`
24-
* `2.0`, `2.0.42`, `stable-2.0.42`
25-
* `2.0`, `2.0.41`, `stable-2.0.41`
26-
* `2.0.40`
27-
* `2.0`, `2.0.39`, `stable-2.0.39`
28-
* `2.0.38`
29-
* `2.0.37`
30-
* `2.0.36`
31-
* `2.0.35`
32-
* `2.0.34`
33-
* `2.0.33`
34-
* `2.0`, `2.0.32`, `stable-2.0.32`
35-
* `2.0.31`
36-
* `2.0`, `2.0.30`, `stable-2.0.30`
37-
* `2.0.29`
38-
* `2.0`, `2.0.28`, `stable-2.0.28`
39-
* `2.0.27`
40-
* `2.0.26`
41-
* `2.0.25`
42-
* `2.0.24`
43-
* `2.0`, `2.0.23`, `stable-2.0.23`
44-
* `2.0.22`
45-
* `2.0`, `2.0.21`, `stable-2.0.21`
46-
* `2.0`, `2.0.20`, `stable-2.0.20`
47-
* `2.0.19`
48-
* `2.0.18`
49-
* `2.0.17`
50-
* `2.0.16`
51-
* `2.0`, `2.0.15`, `stable-2.0.15`
52-
* `2.0`, `2.0.14`, `stable-2.0.14`
53-
* `2.0`, `2.0.13`, `stable-2.0.13`
54-
* `1`, `1.1`, `1.1.110`, `stable-1.1.110`
55-
* `1.0`, `1.0.0`
56-
* `0.17`, `0.17.79`
57-
* `0.16`, `0.16.51`
58-
* `0.15`, `0.15.40`
59-
* `0.14`, `0.14.23`
60-
* `0.13`, `0.13.20`
61-
* `0.12`, `0.12.35`<!-- end autogeneration tags -->
9+
* `latest, 2.0.58`
10+
* `2, 2.0, 2.0.55, stable, stable-2.0.55`
11+
<!-- end autogeneration tags -->
6212

6313
## Tag descriptions
6414

update.sh

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,64 @@ if [[ $experimental_online_version != "$stable_online_version" ]]; then
9191
fi
9292
rm -f -- "$tmpfile"
9393

94-
readme_tags=$(jq --sort-keys 'keys[]' buildinfo.json | tac | (while read -r line
95-
do
96-
tags="$tags\n* "$(jq --sort-keys ".$line.tags | sort | .[]" buildinfo.json | sed 's/"/`/g' | sed ':a; /$/N; s/\n/, /; ta')
97-
done && printf "%s\n\n" "$tags"))
94+
# Generate README tags with logical sorting and de-duplication
95+
# First, collect all unique tags with their versions
96+
declare -A tag_versions
97+
while IFS= read -r version; do
98+
while IFS= read -r tag; do
99+
# If this tag is already seen, compare versions to keep the latest
100+
if [[ -n "${tag_versions[$tag]}" ]]; then
101+
# Compare version strings - keep the higher one
102+
if [[ "$version" > "${tag_versions[$tag]}" ]]; then
103+
tag_versions[$tag]="$version"
104+
fi
105+
else
106+
tag_versions[$tag]="$version"
107+
fi
108+
done < <(jq -r ".\"$version\".tags[]" buildinfo.json)
109+
done < <(jq -r 'keys[]' buildinfo.json | sort -V -r)
110+
111+
# Build the tags list for README
112+
readme_tags=""
113+
# First add the current latest and stable tags
114+
latest_version=$(jq -r 'to_entries | map(select(.value.tags | contains(["latest"]))) | .[0].key' buildinfo.json)
115+
stable_version=$(jq -r 'to_entries | map(select(.value.tags | index("stable"))) | .[0].key' buildinfo.json)
116+
117+
if [[ -n "$latest_version" ]]; then
118+
latest_tags=$(jq -r ".\"$latest_version\".tags | map(select(. == \"latest\" or . == \"$latest_version\")) | join(\", \")" buildinfo.json | sed 's/"/`/g')
119+
readme_tags="${readme_tags}\n* \`${latest_tags}\`"
120+
fi
121+
122+
if [[ -n "$stable_version" ]] && [[ "$stable_version" != "$latest_version" ]]; then
123+
stable_tags=$(jq -r ".\"$stable_version\".tags | sort | join(\", \")" buildinfo.json | sed 's/"/`/g')
124+
readme_tags="${readme_tags}\n* \`${stable_tags}\`"
125+
fi
126+
127+
# Add major.minor tags (e.g., 2.0, 1.1) - only the latest version for each
128+
declare -A major_minor_seen
129+
while IFS= read -r version; do
130+
if [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
131+
major="${BASH_REMATCH[1]}"
132+
minor="${BASH_REMATCH[2]}"
133+
major_minor="$major.$minor"
134+
135+
# Skip if this is the latest or stable version (already added above)
136+
if [[ "$version" == "$latest_version" ]] || [[ "$version" == "$stable_version" ]]; then
137+
continue
138+
fi
139+
140+
# Only add if we haven't seen this major.minor yet
141+
if [[ -z "${major_minor_seen[$major_minor]}" ]]; then
142+
major_minor_seen[$major_minor]=1
143+
tags=$(jq -r ".\"$version\".tags | join(\", \")" buildinfo.json | sed 's/"/`/g')
144+
if [[ -n "$tags" ]]; then
145+
readme_tags="${readme_tags}\n* \`${tags}\`"
146+
fi
147+
fi
148+
fi
149+
done < <(jq -r 'keys[]' buildinfo.json | sort -V -r)
150+
151+
readme_tags="${readme_tags}\n"
98152

99153
perl -i -0777 -pe "s/<!-- start autogeneration tags -->.+<!-- end autogeneration tags -->/<!-- start autogeneration tags -->$readme_tags<!-- end autogeneration tags -->/s" README.md
100154

0 commit comments

Comments
 (0)