This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch release-1.12.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/release-1.12.x by this push:
new 3c3d5abca fix(cmd): compatibility check when not a semver
3c3d5abca is described below
commit 3c3d5abca757975c98b8123300278af00cf1a8df
Author: Pasquale Congiusti <[email protected]>
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 d0ba44dc9..546ba900c 100644
--- a/pkg/cmd/version.go
+++ b/pkg/cmd/version.go
@@ -183,6 +183,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))
+}