From 11b9a9a143c9d3554e8ba77caaf0197900894246 Mon Sep 17 00:00:00 2001 From: Mike Drakos Date: Mon, 15 Sep 2025 11:15:24 -0700 Subject: [PATCH 1/2] Update version number support --- pkg/platform/model/buildplanner/build.go | 41 +++++++++++++++++++----- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/pkg/platform/model/buildplanner/build.go b/pkg/platform/model/buildplanner/build.go index 91abbef701..a0ce7a11e9 100644 --- a/pkg/platform/model/buildplanner/build.go +++ b/pkg/platform/model/buildplanner/build.go @@ -182,28 +182,45 @@ func isWildcardVersion(version string) bool { return strings.Contains(version, ".x") || strings.Contains(version, ".X") } +func normalizeLeadingV(version string) string { + if version == "" { + return version + } + if version[0] == 'v' || version[0] == 'V' { + return version[1:] + } + return version +} + func VersionStringToRequirements(version string) ([]types.VersionRequirement, error) { - if isExactVersion(version) { + original := version + normalized := normalizeLeadingV(version) + originalHasV := len(original) > 0 && (original[0] == 'v' || original[0] == 'V') + if isExactVersion(normalized) { return []types.VersionRequirement{{ types.VersionRequirementComparatorKey: "eq", - types.VersionRequirementVersionKey: version, + types.VersionRequirementVersionKey: original, }}, nil } - if !isWildcardVersion(version) { + if !isWildcardVersion(normalized) { // Ask the Platform to translate a string like ">=1.2,<1.3" into a list of requirements. // Note that: // - The given requirement name does not matter; it is not looked up. - changeset, err := reqsimport.Init().Changeset([]byte("name "+version), "", "", "") + changeset, err := reqsimport.Init().Changeset([]byte("name "+normalized), "", "", "") if err != nil { return nil, locale.WrapInputError(err, "err_invalid_version_string", "Invalid version string") } requirements := []types.VersionRequirement{} for _, change := range changeset { for _, constraint := range change.VersionConstraints { + vr := constraint.Version + if originalHasV && vr != "" && vr[0] != 'v' && vr[0] != 'V' { + vr = "v" + vr + } requirements = append(requirements, types.VersionRequirement{ types.VersionRequirementComparatorKey: constraint.Comparator, - types.VersionRequirementVersionKey: constraint.Version, + types.VersionRequirementVersionKey: vr, }) } } @@ -214,7 +231,7 @@ func VersionStringToRequirements(version string) ([]types.VersionRequirement, er // For example, given a version number of 3.10.x, constraints should be >= 3.10, < 3.11. // Given 2.x, constraints should be >= 2, < 3. requirements := []types.VersionRequirement{} - parts := strings.Split(version, ".") + parts := strings.Split(normalized, ".") for i, part := range parts { if part != "x" && part != "X" { continue @@ -222,18 +239,26 @@ func VersionStringToRequirements(version string) ([]types.VersionRequirement, er if i == 0 { return nil, locale.NewInputError("err_version_wildcard_start", "A version number cannot start with a wildcard") } + gte := strings.Join(parts[:i], ".") + if originalHasV { + gte = "v" + gte + } requirements = append(requirements, types.VersionRequirement{ types.VersionRequirementComparatorKey: types.ComparatorGTE, - types.VersionRequirementVersionKey: strings.Join(parts[:i], "."), + types.VersionRequirementVersionKey: gte, }) previousPart, err := strconv.Atoi(parts[i-1]) if err != nil { return nil, locale.WrapInputError(err, "err_version_number_expected", "Version parts are expected to be numeric") } parts[i-1] = strconv.Itoa(previousPart + 1) + lt := strings.Join(parts[:i], ".") + if originalHasV { + lt = "v" + lt + } requirements = append(requirements, types.VersionRequirement{ types.VersionRequirementComparatorKey: types.ComparatorLT, - types.VersionRequirementVersionKey: strings.Join(parts[:i], "."), + types.VersionRequirementVersionKey: lt, }) } return requirements, nil From e3ab1d799b62baa946cd9c5d32a6ade2f07a24f8 Mon Sep 17 00:00:00 2001 From: Mike Drakos Date: Fri, 19 Sep 2025 11:38:54 -0700 Subject: [PATCH 2/2] Log raw status --- internal/runbits/runtime/runtime.go | 3 +++ pkg/buildplan/buildplan.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/internal/runbits/runtime/runtime.go b/internal/runbits/runtime/runtime.go index 55d4b8ea50..27da331cea 100644 --- a/internal/runbits/runtime/runtime.go +++ b/internal/runbits/runtime/runtime.go @@ -208,6 +208,9 @@ func Update( } buildPlan = commit.BuildPlan() + // Log build plan status + logging.Debug("Build plan status: %s", buildPlan.Status()) + solveSpinner.Stop(locale.T("progress_success")) } diff --git a/pkg/buildplan/buildplan.go b/pkg/buildplan/buildplan.go index 302d7df633..106634555e 100644 --- a/pkg/buildplan/buildplan.go +++ b/pkg/buildplan/buildplan.go @@ -188,6 +188,10 @@ func (b *BuildPlan) IsBuildInProgress() bool { return b.raw.Status == raw.Started || b.raw.Status == raw.Planned } +func (b *BuildPlan) Status() string { + return b.raw.Status +} + // RequestedIngredients returns the resolved requirements of the buildplan as ingredients func (b *BuildPlan) RequestedIngredients() Ingredients { ingredients := Ingredients{}