Simplify parseHelmVersion function to be more readable

Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-08-14 05:28:04 +00:00
parent a4adff73ae
commit c4ebb44d1f
1 changed files with 3 additions and 7 deletions

View File

@ -70,13 +70,9 @@ func parseHelmVersion(versionStr string) (*semver.Version, error) {
}
// Check if version string starts with "v", if not add it
processedVersion := versionStr
if !strings.HasPrefix(strings.TrimSpace(versionStr), "v") {
// Check if it looks like a semantic version (starts with a digit)
trimmed := strings.TrimSpace(versionStr)
if len(trimmed) > 0 && (trimmed[0] >= '0' && trimmed[0] <= '9') {
processedVersion = "v" + trimmed
}
processedVersion := strings.TrimSpace(versionStr)
if !strings.HasPrefix(processedVersion, "v") {
processedVersion = "v" + processedVersion
}
v, err := chartify.FindSemVerInfo(processedVersion)