You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: update version extraction to be more robust, ensure compatibility (#337)
## Description
Update version detection to always detect named module block, and
extract version from same module block.
Ensure that script is completely compatible for all Unix environments.
<!-- Briefly describe what this PR does and why -->
## Type of Change
- [ ] New module
- [X] Bug fix
- [ ] Feature/enhancement
- [ ] Documentation
- [ ] Other
## Testing & Validation
- [ ] Tests pass (`bun test`)
- [X] Code formatted (`bun run fmt`)
- [X] Changes tested locally
version=$(echo "$version_line"| sed -n 's/.*version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p')
239
-
if [ -n"$version" ];then
240
-
log "DEBUG""Found version '$version' from source line: $version_line"
241
-
echo"$version"
242
-
return 0
243
-
fi
235
+
if [ -n"$version" ];then
236
+
log "DEBUG""Found version '$version' from module block for $namespace/$module_name"
237
+
echo"$version"
238
+
return 0
244
239
fi
245
240
246
-
local fallback_version
247
-
fallback_version=$(grep -E 'version[[:space:]]*=[[:space:]]*"[0-9]+\.[0-9]+\.[0-9]+"'"$readme_path"| head -1 | sed 's/.*version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/'||echo"")
241
+
log "DEBUG""No version found in module block for $namespace/$module_name in $readme_path"
242
+
return 1
243
+
}
244
+
245
+
extract_version_from_module_block() {
246
+
local readme_path="$1"
247
+
local namespace="$2"
248
+
local module_name="$3"
249
+
250
+
local version
251
+
version=$(grep -A 10 "source[[:space:]]*=[[:space:]]*\"registry\.coder\.com/${namespace}/${module_name}/coder""$readme_path" \
0 commit comments