chore(payments): Add version structure with minor#103
chore(payments): Add version structure with minor#103Quentin-David-24 wants to merge 4 commits intomainfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
My IDE was not happy with the state of the go mod, it would update automatically this file
| res := semver.Compare(version, "v3.0.0-rc.1") | ||
| switch res { | ||
| case 0, 1: | ||
| controller.SetVersion(V3) | ||
| controller.SetVersion(*paymentVersion) | ||
| return nil | ||
| } | ||
|
|
||
| func computePaymentVersion(rawVersion string) (*Version, error) { | ||
| semverVersion := semver.MajorMinor(rawVersion) | ||
| if semverVersion == "" { | ||
| // we assume the version is a commit id | ||
| // thus corresponds to the latest possible version | ||
| return &Version{Major: V3, Minor: math.MaxInt, Raw: rawVersion}, nil | ||
| } | ||
|
|
||
| parts := strings.Split(semver.Canonical(semverVersion), ".") | ||
| if len(parts) < 2 { | ||
| return nil, fmt.Errorf("expected both major and minor for version string: %s", rawVersion) | ||
| } | ||
|
|
||
| var major PaymentMajorVersion | ||
| minor, _ := strconv.Atoi(parts[1]) | ||
|
|
||
| switch parts[0] { | ||
| case "v0", "v1", "v2": | ||
| major = V1 | ||
| case "v3": | ||
| major = V3 | ||
| default: | ||
| controller.SetVersion(V1) |
There was a problem hiding this comment.
Following that existing piece of code, V0 and V2 does not exist.
There is a lot of places in the codebase where we check for V0. Maybe we should remove those?
| if semverVersion == "" { | ||
| // we assume the version is a commit id | ||
| // thus corresponds to the latest possible version | ||
| return &Version{Major: V3, Minor: math.MaxInt, Raw: rawVersion}, nil |
There was a problem hiding this comment.
So I added MaxInt minor to be sure to capture everything, a bit hacky
| } | ||
|
|
||
| if c.PaymentsVersion < versions.V1 { | ||
| if c.PaymentsVersion.Major < versions.V1 { |
There was a problem hiding this comment.
It might be unreachable now since you cannot get a versions.V0 from version controller
No description provided.