Skip to content

Commit

Permalink
refactor(semantic): simplify comparing of "pre" letters in PyPI versi…
Browse files Browse the repository at this point in the history
…ons (#278)
  • Loading branch information
G-Rath authored Oct 31, 2024
1 parent 674b62d commit f72af0e
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions pkg/semantic/version-pypi.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,6 @@ func (pv PyPIVersion) compareRelease(pw PyPIVersion) int {
return pv.release.Cmp(pw.release)
}

func (pv PyPIVersion) preIndex() int {
for i, pre := range []string{"a", "b", "rc"} {
if pre == pv.pre.letter {
return i
}
}

panic("unknown prefix " + pv.pre.letter)
}

// Checks if this PyPIVersion should apply a sort trick when comparing pre,
// which ensures that i.e. 1.0.dev0 is before 1.0a0.
func (pv PyPIVersion) shouldApplyPreTrick() bool {
Expand Down Expand Up @@ -222,8 +212,8 @@ func (pv PyPIVersion) comparePre(pw PyPIVersion) int {
case pw.pre.number == nil:
return -1
default:
ai := pv.preIndex()
bi := pw.preIndex()
ai := pv.pre.letter[0]
bi := pw.pre.letter[0]

if ai > bi {
return +1
Expand Down

0 comments on commit f72af0e

Please sign in to comment.