This repository was archived by the owner on May 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +31
-6
lines changed Expand file tree Collapse file tree 1 file changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -21,14 +21,39 @@ for dir in "${changed_dirs[@]}"; do
2121 if [[ -f " $dir /README.md" ]]; then
2222 file=" $dir /README.md"
2323 tmpfile=$( mktemp /tmp/tempfile.XXXXXX)
24- awk -v tag=" $LATEST_TAG " ' {
25- if ($1 == "version" && $2 == "=") {
26- sub(/"[^"]*"/, "\"" tag "\"")
27- print
28- } else {
24+ awk -v tag=" $LATEST_TAG " '
25+ BEGIN { in_code_block = 0; in_nested_block = 0 }
26+ {
27+ # Detect the start and end of Markdown code blocks.
28+ if ($0 ~ /^```/) {
29+ in_code_block = !in_code_block
30+ # Reset nested block tracking when exiting a code block.
31+ if (!in_code_block) {
32+ in_nested_block = 0
33+ }
34+ }
35+
36+ # Handle nested blocks within a code block.
37+ if (in_code_block) {
38+ # Detect the start of a nested block (skipping "module" blocks).
39+ if ($0 ~ /{/ && !($1 == "module" || $1 ~ /^[a-zA-Z0-9_]+$/)) {
40+ in_nested_block++
41+ }
42+
43+ # Detect the end of a nested block.
44+ if ($0 ~ /}/ && in_nested_block > 0) {
45+ in_nested_block--
46+ }
47+
48+ # Update "version" only if not in a nested block.
49+ if (!in_nested_block && $1 == "version" && $2 == "=") {
50+ sub(/"[^"]*"/, "\"" tag "\"")
51+ }
52+ }
53+
2954 print
3055 }
31- } ' " $file " > " $tmpfile " && mv " $tmpfile " " $file "
56+ ' " $file " > " $tmpfile " && mv " $tmpfile " " $file "
3257
3358 # Check if the README.md file has changed
3459 if ! git diff --quiet -- " $dir /README.md" ; then
You can’t perform that action at this time.
0 commit comments