Skip to content
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

Fix versioning for shorter version strings #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion googet.goospec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{$version := "2.21.0@0" -}}
{{$version := "2.21.1@0" -}}
{
"name": "googet",
"version": "{{$version}}",
Expand All @@ -15,6 +15,7 @@
"path": "install.ps1"
},
"releaseNotes": [
"2.21.1 - Remove offsets for semver to better support upgrading versions from X.X.X to Y.Y"
"2.21.0 - Add arm64 arch support.",
"2.20.0 - Add installdate metadata to registry key for consumption by external tools.",
"2.19.0 - Updated to Go 1.19.",
Expand Down
6 changes: 2 additions & 4 deletions goolib/goospec.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,12 @@ func fixVer(ver string) string {
}
out := []string{"0", "0", "0"}
nums := strings.SplitN(ver, ".", 3)
offset := len(out) - len(nums)
for i, str := range nums {
trimmed := strings.TrimLeft(str, "0")
if trimmed == "" {
trimmed = "0"
}
out[i+offset] = trimmed
out[i] = trimmed
}
return strings.Join(out, ".") + suffix
}
Expand All @@ -189,8 +188,7 @@ func ComparePriorityVersion(p1 priority.Value, v1 string, p2 priority.Value, v2
func ParseVersion(ver string) (Version, error) {
v := strings.SplitN(ver, "@", 2)
v[0] = fixVer(v[0])

sv, err := semver.Parse(v[0])
sv, err := semver.ParseTolerant(v[0])
if err != nil {
return Version{}, err
}
Expand Down