MCPcopy Index your code
hub / github.com/coder/coder / sortVersionsDesc

Function sortVersionsDesc

scripts/releaser/version.go:94–98  ·  view source on GitHub ↗

sortVersionsDesc sorts a slice of versions in descending order using semver-correct comparison. This is necessary because git's --sort=-v:refname treats pre-release suffixes (e.g. -rc.0) as greater than the release version, which is the opposite of semver where v2.32.0 > v2.32.0-rc.0.

(tags []version)

Source from the content-addressed store, hash-verified

92// greater than the release version, which is the opposite of semver
93// where v2.32.0 > v2.32.0-rc.0.
94func sortVersionsDesc(tags []version) {
95 sort.Slice(tags, func(i, j int) bool {
96 return tags[i].GreaterThan(tags[j])
97 })
98}
99
100// allSemverTags returns all semver tags sorted descending.
101func allSemverTags() ([]version, error) {

Callers 3

TestSortVersionsDescFunction · 0.85
allSemverTagsFunction · 0.85
mergedSemverTagsFunction · 0.85

Calls 1

GreaterThanMethod · 0.80

Tested by 1

TestSortVersionsDescFunction · 0.68