You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/03/17 08:20:15 UTC
[camel-k] branch release-1.10.x updated: fix(cmd): compatibility check when not a semver
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch release-1.10.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/release-1.10.x by this push:
new 30073dd98 fix(cmd): compatibility check when not a semver
30073dd98 is described below
commit 30073dd9842e79449701418f5f34313683c760ee
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Mar 16 15:57:47 2023 +0100
fix(cmd): compatibility check when not a semver
---
pkg/cmd/version.go | 3 +++
pkg/cmd/version_test.go | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go
index 6cec424d6..502ee75f0 100644
--- a/pkg/cmd/version.go
+++ b/pkg/cmd/version.go
@@ -177,6 +177,9 @@ func operatorVersion(ctx context.Context, c client.Client, namespace string) (st
}
func compatibleVersions(aVersion, bVersion string, cmd *cobra.Command) bool {
+ if aVersion == bVersion {
+ return true
+ }
a, err := semver.NewVersion(aVersion)
if err != nil {
fmt.Fprintln(cmd.ErrOrStderr(), "Could not parse '"+aVersion+"' (error:", err.Error()+")")
diff --git a/pkg/cmd/version_test.go b/pkg/cmd/version_test.go
index 7fd7ad489..6ba39d067 100644
--- a/pkg/cmd/version_test.go
+++ b/pkg/cmd/version_test.go
@@ -86,3 +86,9 @@ func TestCompatibleVersions(t *testing.T) {
assert.Equal(t, false, compatibleVersions("1.3.0", "dsadsa", rootCmd))
assert.Equal(t, false, compatibleVersions("dsadsa", "1.3.4", rootCmd))
}
+
+func TestCompatibleVersionsNonSemver(t *testing.T) {
+ _, rootCmd, _ := initializeVersionCmdOptions(t)
+ assert.Equal(t, true, compatibleVersions("1.3.0.special-version", "1.3.0.special-version", rootCmd))
+ assert.Equal(t, false, compatibleVersions("1.3.1.special-version", "1.3.0.special-version", rootCmd))
+}