Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
release: Fix release candidate to major version upgrade check
Browse files Browse the repository at this point in the history
Fix `kata-runtime kata-check`'s network version check which was failing
when the user was running a release candidate build and the latest
release was a major one, two examples of the error being:

- `BUG: unhandled scenario: current version: 1.12.0-rc0, latest version: 1.12.0`
- `BUG: unhandled scenario: current version: 2.0.0-rc0, latest version: 2.0.0`

Fixes: #3069.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Nov 12, 2020
1 parent 8fbf9aa commit fc6beea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cli/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ func getNewReleaseType(current semver.Version, latest semver.Version) (string, e
}
} else if latest.Patch == current.Patch && len(latest.Pre) > 0 {
desc = "pre-release"
} else if latest.Major == current.Major &&
latest.Minor == current.Minor &&
latest.Patch == current.Patch {
if len(current.Pre) > 0 && len(latest.Pre) == 0 {
desc = "major"
}
} else {
return "", fmt.Errorf("BUG: unhandled scenario: current version: %s, latest version: %s", current, latest)
}
Expand Down
6 changes: 6 additions & 0 deletions cli/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,12 @@ func TestGetNewReleaseType(t *testing.T) {
{"1.0.0", "1.0.3", false, "patch"},
{"1.0.0-beta29", "1.0.0-beta30", false, "pre-release"},
{"1.0.0", "1.0.3-alpha99.1b", false, "patch pre-release"},

{"2.0.0-rc0", "2.0.0", false, "major"},
{"2.0.0-rc1", "2.0.0", false, "major"},

{"1.12.0-rc0", "1.12.0", false, "major"},
{"1.12.0-rc5", "1.12.0", false, "major"},
}

for i, d := range data {
Expand Down

0 comments on commit fc6beea

Please sign in to comment.