File tree 1 file changed +31
-6
lines changed
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
21
21
if [[ -f " $dir /README.md" ]]; then
22
22
file=" $dir /README.md"
23
23
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
+
29
54
print
30
55
}
31
- } ' " $file " > " $tmpfile " && mv " $tmpfile " " $file "
56
+ ' " $file " > " $tmpfile " && mv " $tmpfile " " $file "
32
57
33
58
# Check if the README.md file has changed
34
59
if ! git diff --quiet -- " $dir /README.md" ; then
You can’t perform that action at this time.
0 commit comments