@@ -37,7 +37,7 @@ const (
3737 rc = releasePhase (3 )
3838 cloudonly = releasePhase (4 )
3939 stable = releasePhase (5 )
40- custom = releasePhase (6 )
40+ adhoc = releasePhase (6 )
4141)
4242
4343// Version represents a CockroachDB (binary) version. Versions consist of three parts:
@@ -53,11 +53,11 @@ type Version struct {
5353 // the fields are compared in the order listed here, and the earliest field with
5454 // a difference determines the relative ordering of two unequal versions.
5555 //
56- // The reference order: year, ordinal, patch, phase, phaseOrdinal, phaseSubOrdinal, nightlyOrdinal
57- year , ordinal , patch int
58- phase releasePhase
59- phaseOrdinal , phaseSubOrdinal , nightlyOrdinal int
60- customLabel string
56+ // The reference order: year, ordinal, patch, phase, phaseOrdinal, phaseSubOrdinal, customOrdinal
57+ year , ordinal , patch int
58+ phase releasePhase
59+ phaseOrdinal , phaseSubOrdinal , customOrdinal int
60+ adhocLabel string
6161 // raw is the original, unprocessed string this Version was created with
6262 raw string
6363}
@@ -82,7 +82,7 @@ func (v Version) Patch() int {
8282// - %p: phase sort order (see the top of version.go)
8383// - %o: phase ordinal (eg, the 1 in "v24.1.0-rc.1")
8484// - %s: phase sub-ordinal (eg the 2 in "v24.1.0-rc.1-cloudonly.2")
85- // - %n: nightly ordinal (eg the 12 in "v24.1.0-12-gabcdef")
85+ // - %n: adhoc build ordinal (eg the 12 in "v24.1.0-12-gabcdef")
8686// - %%: literal "%"
8787func (v Version ) Format (formatStr string ) string {
8888 placeholderRe := regexp .MustCompile ("%[^%XYZpPosn]" )
@@ -96,7 +96,7 @@ func (v Version) Format(formatStr string) string {
9696 beta : "beta" ,
9797 rc : "rc" ,
9898 cloudonly : "cloudonly" ,
99- custom : "" ,
99+ adhoc : "" ,
100100 stable : "" ,
101101 }
102102
@@ -107,7 +107,7 @@ func (v Version) Format(formatStr string) string {
107107 formatStr = strings .ReplaceAll (formatStr , "%P" , phaseName [v .phase ])
108108 formatStr = strings .ReplaceAll (formatStr , "%o" , strconv .Itoa (v .phaseOrdinal ))
109109 formatStr = strings .ReplaceAll (formatStr , "%s" , strconv .Itoa (v .phaseSubOrdinal ))
110- formatStr = strings .ReplaceAll (formatStr , "%n" , strconv .Itoa (v .nightlyOrdinal ))
110+ formatStr = strings .ReplaceAll (formatStr , "%n" , strconv .Itoa (v .customOrdinal ))
111111 formatStr = strings .ReplaceAll (formatStr , "%%" , "%" )
112112 return formatStr
113113}
@@ -171,9 +171,19 @@ func (v Version) IsPrerelease() bool {
171171 return v .phase < cloudonly && ! v .Empty ()
172172}
173173
174- // IsCustomOrNightlyBuild determines if the version is a custom build or nightly build.
175- func (v Version ) IsCustomOrNightlyBuild () bool {
176- return v .nightlyOrdinal > 0
174+ // IsCustomOrAdhocBuild determines if the version is a adhoc build or adhoc build.
175+ func (v Version ) IsCustomOrAdhocBuild () bool {
176+ return v .IsCustomBuild () || v .IsAdhocBuild ()
177+ }
178+
179+ // IsCustomBuild determines if the version is a adhoc build.
180+ func (v Version ) IsCustomBuild () bool {
181+ return v .customOrdinal > 0
182+ }
183+
184+ // IsAdhocBuild determines if the version is a adhoc build.
185+ func (v Version ) IsAdhocBuild () bool {
186+ return v .adhocLabel != ""
177187}
178188
179189// IsCloudOnlyBuild determines if the version is a CockroachDB Cloud specific build.
@@ -197,17 +207,17 @@ func Parse(str string) (Version, error) {
197207 patterns := []* regexp.Regexp {
198208 regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))(?:-fips)?$` ),
199209 regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<phase>alpha|beta|rc|cloudonly)\.(?P<phaseOrdinal>[0-9]+)(?:-fips)?$` ),
200- regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<nightlyOrdinal >(?:[1-9][0-9]*|0))-g[a-f0-9]+(?:-fips)?$` ),
201- regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<phase>alpha|beta|rc|cloudonly).(?P<phaseOrdinal>[0-9]+)-(?P<nightlyOrdinal >(?:[1-9][0-9]*|0))-g[a-f0-9]+(?:-fips)?$` ),
210+ regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<customOrdinal >(?:[1-9][0-9]*|0))-g[a-f0-9]+(?:-fips)?$` ),
211+ regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<phase>alpha|beta|rc|cloudonly).(?P<phaseOrdinal>[0-9]+)-(?P<customOrdinal >(?:[1-9][0-9]*|0))-g[a-f0-9]+(?:-fips)?$` ),
202212 regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<phase>alpha|beta|rc|cloudonly).(?P<phaseOrdinal>[0-9]+)-cloudonly(-rc|\.)(?P<phaseSubOrdinal>(?:[1-9][0-9]*|0))$` ),
203213 regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<phase>cloudonly)-rc(?P<phaseOrdinal>[0-9]+)$` ),
204214 regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<phase>cloudonly)(?P<phaseOrdinal>[0-9]+)?$` ),
205215
206216 // vX.Y.Z-<anything> will sort after the corresponding "plain" vX.Y.Z version
207- regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<customLabel >[-a-zA-Z0-9\.\+]+)$` ),
217+ regexp .MustCompile (`^v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)\.(?P<patch>(?:[1-9][0-9]*|0))-(?P<adhocLabel >[-a-zA-Z0-9\.\+]+)$` ),
208218
209219 // sha256:<hash>:latest-vX.Y-build will sort just after vX.Y.0, but before vX.Y.1
210- regexp .MustCompile (`^sha256:(?P<customLabel >[^:]+):latest-v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)-build$` ),
220+ regexp .MustCompile (`^sha256:(?P<adhocLabel >[^:]+):latest-v(?P<year>[1-9][0-9]*)\.(?P<ordinal>[1-9][0-9]*)-build$` ),
211221 }
212222
213223 preReleasePhase := map [string ]releasePhase {
@@ -257,15 +267,15 @@ func Parse(str string) (Version, error) {
257267 }
258268 }
259269
260- // nightly/custom builds, eg -10-g7890abcd
261- if ord := submatch (pat , matches , "nightlyOrdinal " ); ord != "" {
262- v .nightlyOrdinal , _ = strconv .Atoi (ord )
270+ // adhoc/adhoc builds, eg -10-g7890abcd
271+ if ord := submatch (pat , matches , "customOrdinal " ); ord != "" {
272+ v .customOrdinal , _ = strconv .Atoi (ord )
263273 }
264274
265- // arbitrary/custom build tags; we have these old versions and need to parse them
266- if customLabel := submatch (pat , matches , "customLabel " ); customLabel != "" {
267- v .phase = custom
268- v .customLabel = customLabel
275+ // arbitrary/adhoc build tags; we have these old versions and need to parse them
276+ if adhocLabel := submatch (pat , matches , "adhocLabel " ); adhocLabel != "" {
277+ v .phase = adhoc
278+ v .adhocLabel = adhocLabel
269279 }
270280
271281 return v , nil
@@ -296,12 +306,12 @@ func MustParse(str string) Version {
296306// rc, cloudonly. Pre-release versions will look like "v24.1.0-cloudonly.1"
297307// or "v23.2.0-rc.1".
298308//
299- // Additionally, we have custom builds, which have suffixes like "-<n>-g<hex>",
309+ // Additionally, we have adhoc builds, which have suffixes like "-<n>-g<hex>",
300310// where <n> is an integer commit count past the branch point, and <hex> is
301311// the git SHA. These versions sort AFTER the corresponding "normal" version,
302312// eg "v24.1.0-1-g9cbe7c5281" is AFTER "v24.1.0".
303313//
304- // A version can have both a pre-release and custom build suffix, like
314+ // A version can have both a pre-release and adhoc build suffix, like
305315// "v24.1.0-rc.2-14-g<hex>". In these cases, the pre-release portion has precedence,
306316// so this example would sort after v24.1.0-rc.2, but before v24.1.0-rc.3.
307317func (v Version ) Compare (w Version ) int {
@@ -323,10 +333,10 @@ func (v Version) Compare(w Version) int {
323333 if rslt := cmp .Compare (v .phaseSubOrdinal , w .phaseSubOrdinal ); rslt != 0 {
324334 return rslt
325335 }
326- if rslt := cmp .Compare (v .nightlyOrdinal , w .nightlyOrdinal ); rslt != 0 {
336+ if rslt := cmp .Compare (v .customOrdinal , w .customOrdinal ); rslt != 0 {
327337 return rslt
328338 }
329- if rslt := cmp .Compare (v .customLabel , w .customLabel ); rslt != 0 {
339+ if rslt := cmp .Compare (v .adhocLabel , w .adhocLabel ); rslt != 0 {
330340 return rslt
331341 }
332342 return 0
0 commit comments