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

pkg/plugin/plugin.go: correct version stage comparison #1552

Merged
merged 1 commit into from
Jun 5, 2020
Merged
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
5 changes: 2 additions & 3 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ func (v Version) Compare(vp Version) int {
if s == sp {
return 0
}
// Since stages are not equal, if s is greater it must either be: beta when sp is alpha
// or "", or alpha when sp is "", otherwise it is lesser.
if s == BetaStage || (s == AlphaStage && sp == "") {
// Since stages are not equal, check: stable > beta > alpha.
if s == "" || (s == BetaStage && sp == AlphaStage) {
return 1
}
} else if v.Number > vp.Number {
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ var _ = g.Describe("Compare", func() {
}

sortedVersions = []Version{
{Number: 1},
{Number: 1, Stage: AlphaStage},
{Number: 1},
{Number: 2, Stage: AlphaStage},
{Number: 2, Stage: BetaStage},
{Number: 4},
{Number: 4, Stage: AlphaStage},
{Number: 4, Stage: BetaStage},
{Number: 4},
{Number: 30},
{Number: 44, Stage: AlphaStage},
{Number: 44, Stage: AlphaStage},
Expand Down