From 228d3dff6ca66ec3a04c9a26319cec2da2d679a7 Mon Sep 17 00:00:00 2001 From: Filipe Constantinov Menezes Date: Wed, 28 Oct 2026 10:25:15 +0000 Subject: [PATCH] CLOUDP-453194: Point the version checker at mongodb-cli and accept the new vX.Y.Z tag format The notifier has queried the mongodb/mongodb-atlas-cli repo since the Jan 2025 repo split (the const was last correct when both tools released from that one repo), so released mongocli binaries never saw any mongocli release. Point it at mongodb/mongodb-cli and port the atlas-cli matcher: legacy mongocli/vX.Y.Z and new bare vX.Y.Z are valid, any other tool's tag (e.g. pre-split atlascli/vX.Y.Z) or non-version tag is rejected. --- internal/latestrelease/finder.go | 23 ++++++++++++++++++++++- internal/latestrelease/finder_test.go | 14 +++++++++++++- internal/version/release_version.go | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/internal/latestrelease/finder.go b/internal/latestrelease/finder.go index a58cfd34b..bbd4b4306 100644 --- a/internal/latestrelease/finder.go +++ b/internal/latestrelease/finder.go @@ -69,8 +69,29 @@ func VersionFromTag(ver string) string { return ver } +// isValidTagForTool reports whether a release tag belongs to MongoCLI and +// carries a valid version. It accepts both the legacy "mongocli/vX.Y.Z" tags +// and the new bare "vX.Y.Z" tags, while rejecting tags for other tools such as +// "atlascli/vX.Y.Z" (which exist in this repo from before it was renamed to +// mongodb-atlas-cli). func isValidTagForTool(tag string) bool { - return !strings.Contains(tag, "atlascli") + switch { + case strings.HasPrefix(tag, config.MongoCLI+"/"): + // Legacy format: mongocli/vX.Y.Z + return isVersionTag(VersionFromTag(tag)) + case strings.Contains(tag, "/"): + // Another tool's tag, e.g. atlascli/vX.Y.Z + return false + default: + // New format: vX.Y.Z. The "v" prefix is required so unrelated tags + // (e.g. a bare "2024") are not coerced into a version. + return strings.HasPrefix(tag, "v") && isVersionTag(tag) + } +} + +func isVersionTag(tag string) bool { + _, err := semver.NewVersion(tag) + return err == nil } func (f *finder) loadOrGet() (*ReleaseInformation, *semver.Version, error) { diff --git a/internal/latestrelease/finder_test.go b/internal/latestrelease/finder_test.go index 503ca315d..1f32ce240 100644 --- a/internal/latestrelease/finder_test.go +++ b/internal/latestrelease/finder_test.go @@ -124,9 +124,21 @@ func TestOutputOpts_testIsValidTag(t *testing.T) { tag string isValid bool }{ - {"atlascli/v1.0.0", false}, + // Legacy format. {"mongocli/v1.0.0", true}, + {"mongocli/v2.0.9", true}, + {"mongocli/v1.0.0-rc0", true}, + // New bare format. {"v1.0.0", true}, + {"v2.3.4", true}, + // Other tools' tags. atlascli tags exist in this repo from before it + // was renamed to mongodb-atlas-cli, so they must never match. + {"atlascli/v1.0.0", false}, + {"atlascli/v1.59.0", false}, + // Tags that do not carry a version. + {"nightly", false}, + {"mongocli/nightly", false}, + {"2024", false}, } for _, tt := range tests { diff --git a/internal/version/release_version.go b/internal/version/release_version.go index ed62577e6..b2bae7db8 100644 --- a/internal/version/release_version.go +++ b/internal/version/release_version.go @@ -43,7 +43,7 @@ type releaseVersionFetcher struct { const ( owner = "mongodb" - project = "mongodb-atlas-cli" + project = "mongodb-cli" ) // LatestWithCriteria retrieves the first release version that matches the criteria. We assume that ListReleases returns releases sorted by created_at value.