Skip to content

Commit 325d78a

Browse files
author
Luca Prete
committed
Changes
1 parent 2977c08 commit 325d78a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tools/change_fabric_ref.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# you may not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
88
#
9-
# https://www.apache.org/licenses/LICENSE-2.0
9+
# https://www.apache.org/licenses/LICENSE-2.0
1010
#
1111
# Unless required by applicable law or agreed to in writing, software
1212
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,19 +26,15 @@ fi
2626
TARGET_DIR="$1"
2727
NEW_VERSION="$2"
2828

29-
# Define the pattern to search for and the new suffix
30-
PATTERN="github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/"
29+
PREFIX="github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/"
3130
NEW_SUFFIX="?ref=$NEW_VERSION"
3231

3332
# Set locale to C to avoid character encoding issues with sed
3433
export LC_CTYPE=C
3534

3635
# Find and replace strings in .tf files, excluding .terraform directories
3736
find "$TARGET_DIR" -type f -name "*.tf" -not -path "*/.terraform/*" -print0 | while IFS= read -r -d $'\0' file; do
38-
# Corrected sed command
39-
# Replaces the entire '?ref=v...' with the new suffix.
40-
# The backslashes `\\` before the first `?` are removed because it's no longer a capture group.
41-
sed -i "s|${PATTERN}[^\"[:space:]]*\\?ref=v[0-9.]*\"|&${NEW_SUFFIX}\"|g" "$file"
37+
sed -i "s|\\(\"$PREFIX[^\"?[:space:]]*\\)?ref=v[0-9.]*\"|\\1$NEW_SUFFIX\"|g" "$file"
4238
done
4339

4440
# Unset the locale variable

0 commit comments

Comments
 (0)