Skip to content

Commit b9c8c4f

Browse files
committed
refactor: Simplify GIT_TAG line replacement logic
- Always replace entire line content after GIT_TAG - Removes potentially outdated version-specific comments - Simplifies regex pattern (no separate hash/tag logic needed) - Cleaner and more predictable behavior
1 parent e0b5a39 commit b9c8c4f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

updater/scripts/cmake-functions.ps1

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,9 @@ function Update-CMakeFile($filePath, $depName, $newValue) {
113113
$replacement = $newValue
114114
}
115115

116-
# Update GIT_TAG value, preserving formatting
117-
if ($wasHash) {
118-
# For hash updates, replace everything after GIT_TAG on that line (including existing comments)
119-
$pattern = "(FetchContent_Declare\s*\(\s*$depName\s+[^)]*GIT_TAG\s+)[^\r\n]+(\r?\n[^)]*\))"
120-
} else {
121-
# For tag updates, preserve existing structure
122-
$pattern = "(FetchContent_Declare\s*\(\s*$depName\s+[^)]*GIT_TAG\s+)\S+(\s*[^)]*\))"
123-
}
116+
# Update GIT_TAG value, replacing entire line content after GIT_TAG
117+
# This removes potentially outdated version-specific comments
118+
$pattern = "(FetchContent_Declare\s*\(\s*$depName\s+[^)]*GIT_TAG\s+)[^\r\n]+(\r?\n[^)]*\))"
124119
$newContent = [regex]::Replace($content, $pattern, "`${1}$replacement`${2}", 'Singleline')
125120

126121
if ($newContent -eq $content) {

0 commit comments

Comments
 (0)