-
Notifications
You must be signed in to change notification settings - Fork 0
chore(payments): Add version structure with minor #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be unreachable now since you cannot get a versions.V0 from version controller
No description provided.