Skip to content

Commit

Permalink
Merge pull request #1552 from estroz/bugfix/version-compare
Browse files Browse the repository at this point in the history
pkg/plugin/plugin.go: correct version stage comparison
  • Loading branch information
k8s-ci-robot committed Jun 5, 2020
2 parents 6e0d3d4 + 493cc6e commit 34037b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
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

0 comments on commit 34037b3

Please sign in to comment.