From f520a3670b10cbc680698b8945f0ffb2d3d5d09f Mon Sep 17 00:00:00 2001 From: xixi Date: Tue, 20 Jun 2023 18:09:10 +0800 Subject: [PATCH] fix client version parser (#673) Signed-off-by: xixi --- pkg/juicefs/juicefs.go | 2 +- pkg/juicefs/juicefs_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/juicefs/juicefs.go b/pkg/juicefs/juicefs.go index a40a856aff..4bd6656c32 100644 --- a/pkg/juicefs/juicefs.go +++ b/pkg/juicefs/juicefs.go @@ -101,7 +101,7 @@ func parseRawVersion(rawVersion string) (*clientVersion, error) { } func parseVersion(version string) (*clientVersion, error) { - re := regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$`) + re := regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)(?:[+-](.+))?$`) matches := re.FindStringSubmatch(strings.TrimSpace(version)) if matches == nil { return nil, fmt.Errorf("invalid version string: %s", version) diff --git a/pkg/juicefs/juicefs_test.go b/pkg/juicefs/juicefs_test.go index ec3db96aaf..00cfa85638 100644 --- a/pkg/juicefs/juicefs_test.go +++ b/pkg/juicefs/juicefs_test.go @@ -1313,6 +1313,15 @@ func Test_parseRawVersion(t *testing.T) { Patch: 0, }, }, + { + name: "test-normal5", + raw: "juicefs version 1.0.4+2023-04-06.f1c475d9", + want: clientVersion{ + Major: 1, + Minor: 0, + Patch: 4, + }, + }, { name: "test-error", raw: "juicefs version 0.11",