Skip to content

Commit 247ba17

Browse files
committed
STAC-22609: Fix comment and test
1 parent 707307e commit 247ba17

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

cmd/stackpack/stackpack_test_cmd.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ func RunStackpackTestCommand(args *TestArgs) di.CmdWithApiFn {
248248

249249
// bumpSnapshotVersionWithBase increments cli-test version using a different base version for computation
250250
// Logic: If baseVersion contains "-cli-test.N", increments N to N+1
251-
// If no cli-test suffix exists, adds "-cli-test.1" to the base version
252-
// Examples: "1.0.0" -> "1.0.0-cli-test.1", "1.0.0-cli-test.5" -> "1.0.0-cli-test.6"
251+
// If no cli-test suffix exists, adds "-cli-test.10000" to the base version (high number for alphanumeric ordering)
252+
// Examples: "1.0.0" -> "1.0.0-cli-test.10000", "1.0.0-cli-test.10005" -> "1.0.0-cli-test.10006"
253253
func bumpSnapshotVersionWithBase(configPath, baseVersion string) (string, error) {
254254
// Parse the base version using semver
255255
version, err := semver.Parse(baseVersion)
@@ -273,15 +273,15 @@ func bumpSnapshotVersionWithBase(configPath, baseVersion string) (string, error)
273273
var currentNum uint64
274274

275275
// Extract current cli-test number (handles both numeric and string formats)
276-
if nextPart.VersionStr == "" {
276+
if nextPart.IsNumeric() {
277277
// Numeric format: use VersionNum directly
278278
currentNum = nextPart.VersionNum
279279
} else if num, err := strconv.ParseUint(nextPart.VersionStr, 10, 64); err == nil {
280280
// String format: parse to number
281281
currentNum = num
282282
} else {
283-
// Invalid format: reset to cli-test.1
284-
newVersion = fmt.Sprintf("%d.%d.%d-cli-test.1", version.Major, version.Minor, version.Patch)
283+
// Invalid format: reset to cli-test.10000
284+
newVersion = fmt.Sprintf("%d.%d.%d-cli-test.10000", version.Major, version.Minor, version.Patch)
285285
return newVersion, updateVersionInHocon(configPath, newVersion)
286286
}
287287

@@ -292,7 +292,7 @@ func bumpSnapshotVersionWithBase(configPath, baseVersion string) (string, error)
292292
case i == cliTestIndex+1:
293293
// Increment the cli-test number
294294
newPreParts[i] = fmt.Sprintf("%d", currentNum+1)
295-
case pre.VersionStr == "":
295+
case pre.IsNumeric():
296296
// Convert numeric pre-release parts to string
297297
newPreParts[i] = fmt.Sprintf("%d", pre.VersionNum)
298298
default:
@@ -302,8 +302,8 @@ func bumpSnapshotVersionWithBase(configPath, baseVersion string) (string, error)
302302
}
303303
newVersion = fmt.Sprintf("%d.%d.%d-%s", version.Major, version.Minor, version.Patch, strings.Join(newPreParts, "."))
304304
} else {
305-
// No cli-test found: add initial cli-test.1 suffix
306-
newVersion = fmt.Sprintf("%d.%d.%d-cli-test.1", version.Major, version.Minor, version.Patch)
305+
// No cli-test found: add initial cli-test.10000 suffix
306+
newVersion = fmt.Sprintf("%d.%d.%d-cli-test.10000", version.Major, version.Minor, version.Patch)
307307
}
308308

309309
return newVersion, updateVersionInHocon(configPath, newVersion)

cmd/stackpack/stackpack_test_cmd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestBumpSnapshotVersion(t *testing.T) {
5959
{
6060
name: "first cli-test version",
6161
currentVersion: "1.0.0",
62-
expectedVersion: "1.0.0-cli-test.1",
62+
expectedVersion: "1.0.0-cli-test.10000",
6363
},
6464
{
6565
name: "increment existing cli-test",

0 commit comments

Comments
 (0)