-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Semver parsing does not terminate CRLF making it returns v0.0.0 when parsing #5526
Comments
This issue is currently awaiting triage. SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I'm not seeing the same behavior that you're seeing. If it were failing the way you've described, then I would expect to see failures in semver_test.go, particularly TestParse/two. I tried adding this testcase into func Test5526(t *testing.T) {
expected := SemVer{major: 0, minor: 15, patch: 1}
actual, err := Parse("v0.15.1")
if err != nil {
t.Errorf("Unexpected error: '%s'", err)
}
if !actual.Equals(expected) {
t.Errorf("Not equal: '%s' and '%s'", actual, expected)
}
if actual.String() != "v0.15.1" {
t.Errorf("String for '%s' not as expected", actual)
}
} Will you detail further how to repeat the failure? Thanks. |
Hi @antoooks |
Hi @ephesused thanks for pointing that out. The issue happens when I used I split the branch name string to extract the version number After that I supplied the Will change the title and description accordingly |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
Looking at this one again, I would recommend that the caller trim its whitespace prior to invoking I see different behavior than you do when I try to parse
I added this locally to
That fits what I would expect. Based on what I'm seeing, I believe If |
Thanks for pointing it out, I have included trim inside Parse() on my PR (#5449) because I need it for the feature I'm working on. I see your point and will include such testing on my changes as well |
Hi @ephesused , I am able to reproduce the condition. So you cannot use And secondly, throwing error means it works as expected. It's just that the test does not consume the return value and only look for the error that is being thrown together with On the source code you can see this conditional: // kustomize/cmd/gorepomod/internal/semver.go, L55-58
n[i], err = strconv.Atoi(fields[i])
if err != nil {
return zero, err
} Which makes it supposedly throw |
Sorry, I don't understand what you're describing. If you have a test case that shows the incorrect From what I see, |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close not-planned |
@k8s-triage-robot: Closing this issue, marking it as "Not Planned". In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What happened?
internal libary
cmd/gorepomod/internal/semver/semver.go
has a functionParse(raw string)
which translate a raw string into Semver object. However, if we supply string with CRLF (\r\n
), it will return a default behaviorzero
which translates tov0.0.0
. This makessemver.Parse()
function cannot translate kustomize libarary current versioning e.g. kyaml right now isv0.15.1
due to Git commands returns results with CRLF.Note: the function will not throw an error, but it will throw a default behavior
What did you expect to happen?
The correct behavior
semver.Parse("v0.15.1")
will result&Semver{major: 0, minor: 15, patch: 1}
How can we reproduce it (as minimally and precisely as possible)?
Usage:
Expected output
Actual output
Kustomize version
v5.3.0
Operating system
Linux
The text was updated successfully, but these errors were encountered: